Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 2

using System;

namespace Day1
{
class AddorSubtraction {
static void Main(String[] args)
{
int firstNumber;
int secondNumber;
string choice;
char flag ="Y"
Console.Writeline("Enter 1st number");
fisrtNumber= int.Parse(Console.ReadLine());
Console.WriteLine("enter a 2nd number");
secondNumber=int.Parse(Console.ReadLine());
while(flag==true)
Console.Writeline("Which operation do you want to perform?");
choice=Console.ReadLine();

if(choice=="add")
{
int sum= firstNumber+ secondNumber;
Console.WriteLine("The sum Of {0} and {1} is {2}", firstNumber, secondNumber,sum);
}
elseif(choice=="sub")
{
int sub= firstNumber- secondNumber;
Console.WriteLine("The subOf {0} and {1} is {2}", firstNumber, secondNumber,sum);
}
else
{
Console.WriteLine("you entered wrong choice");
}
Console.WriteLine("Do you want to continue?press Y or N:");
flag =Console.readline()[0];
}
}
}
}
zamnegoy@gmail.com
Create a class called Person in Java that has the following attributes, constructor
and methods:
Attributes:
i) name (string);
ii) surname (string);
iii) age (integer);
iv) address (string);
Constructors
i) a default constructor;
ii) a parameterized constructor;
Methods
i) a method to return the value of the name;
ii) a method to return the value of surname;
iii) a method to set a new address;

Write a test class called PersonTest with a main method that carries out the
following steps:
i) Construct one or more objects of the class that is being
tested
ii) Invoke one or more methods
iii) Print out one or more results

You might also like