Project A7 Instructions(Deadline 11/7/22 EST):
Calculator Version 1
Create a Console project.
Rename “Program.cs” to “CalculatorRun.cs” (10%)
Create a class file “Calculator.cs” (50%)
– 3 private double data members with three public properties
– firstOperand, FirstOperand;
– secondOperand, SecondOperand;
– result, Result;
– 1 public method Addition()
– do addition in this method, Result = FirstOperand + SecondOperand;
In “CalculatorRun.cs”, have users to enter values for firstOperand and secondOperand,
show addtion result. (40%)
Project A8 Instructions)Deadline 11/16/22 EST):
Create a console project, create two cs files.
Create a Student.cs class (5%). Do followings in Student class.
Declare these data members:
1. a static int Count. (15%)
2. a private static readonly Random variable rnd. (15%)
private static readonly Random rnd = new Random();
3. private string firstName, lastName, int sID, create public properties for these three data members. (20%)
4. Two constructors
a). Constructor 1: public Student(string first , string last , int id) (20%)
—-this constructor set values for firstName, lastName, sID, and increase Count value by 1.
b). Constructor 2: public Student(string first=””, string last = “”) (20%)
—-This constructor set values for firstName, lastName, and increase Count value by 1.
—-Create StudentID by calling rnd.Next(1000,9999).
—-Note this constructor is called when
Student s1 = new Student();
Student s2 = new Student(“Peter”);
Student s3 = new Student(“Morgan”, “Simmons”);
Create “Program.cs” to have main() (5%)
static void Main(string[] args)
{
Student s1 = new Student();
s1.FirstName = “John”;
s1.LastName = “Smith”;
s1.StudentID = 2560;
Student s2 = new Student(“Peter”);
Student s3 = new Student(“Morgan”, “Simmons”);
Student s4 = new Student(“James”, “Walters”);
Student s5 = new Student(“Linda”, “Scott”, 1005);
Console.WriteLine();
Console.WriteLine(“Total students: {0}”, Student.Count);
//use Console.WriteLine to display s1, s2, s3, s4, s5 Name and Student ID.
}
Project A9 Instructions (Deadline 12/1/22 EST):
3 cs files to be created.
1. Create a class “DSC.cs”.
— One data memeber: private string schoolName, set default value to “Daytona State College”. Create a property for it. (10%)
— Create a method “public virtual string ShowAddress()”, 10%)
return ” 1200 W. International Speedway Blvd., Daytona Beach, Florida 32114 “;
2. Create a class “Campus.cs”, inheritate “DSC.cs”.
— One data memeber: private string campusName. Create a property for it. (10%)
— Create a constructor “public Campus(string cName)”, set value for campusName. (10%)
— override ShowAddress(), return ” 1770 Williamson Blvd., Daytona Beach, Florida 32117 “; (15%)
— Create “public string Departments()”, (15%)
return “Computer Scinece Department, Emergency Care Department, Police Academy”;
— override ToString(), use above properties and methods to display the following result when it is called.
Daytona State College Advanced Technology College (15%)
is located at 1770 Williamson Blvd., Daytona Beach, Florida 32117,
it has Computer Scinece Department, Emergency Care Department, Police Academy
3. Create “Program.cs”, (15%)
in main():
static void Main(string[] args)
{
Campus atc = new Campus(“Advanced Technology College”);
Console.WriteLine(atc.ToString());
}
Project A10 Instructions(Deadline 12/7/22 EST):
Create a console project.
1. Create an interface “IMyInterface.cs” (10%)
– Add a method “string iMessage()”
2. Create a class named “C1.cs”
– Add 4 private data members, create property for each data member (10%)
double loanAmnout=0.0;
double years=0.0;
double interests=0.0;
double interestRate=0.0;
– Add a constructor with parameters to assign values to loanAmnout, years, interestRate with values that user entered. (20%)
– Add one method “PayInterests()” to return the interests (20%)
interests = loanAmnout * interestRate * years
– Inheritate “IMyInterface”, implement the method ” iMessage()”, (20%)
return string “Be Ready!”
3. In Program.cs, have users to enter loanAmnout, years, interestRate. (20%)
– Call method PayInterests() to display total interests.
– Call iMessage() to display “Be Ready!”
Project A11 Instructions (Deadline 12/11/22 EST)(might be connected to A10):
Continue with Assignment “Loan Program”. Read code “SquareRootTest” (demoed in lecture video).
1. Create a class “MyRangeException.cs” (similar to example code). (20%)
2. In “Program.cs”, in main(), Add Exception Handling (20%)
class Program
{
public static double loanAmount;
public static double years;
public static double interest;
static void Main(string[] args)
{
…..
//for loanAmount
do {
try
{
Console.Write(“Please enter the loan amount: $”);
loanAmount = Convert.ToDouble(Console.ReadLine());
CheckLoanAmount (loanAmount);
continueLoop = false;
}
catch ( FormatException formatException )
{
Console.WriteLine( “\n” + formatException.Message );
Console.WriteLine( “Please enter a double value.\n” );
} // end catch
catch (MyRangeException negativeNumberException )
{
Console.WriteLine( “\n” + negativeNumberException.Message );
//Console.WriteLine( “Please enter a non-negative value.\n” );
} // end catch
} while (continueLoop);
…..
//for years
do {
}while ( continueLoop );
…..
//for interest
do {
}while ( continueLoop );
}
…..
}
Requirement (similar to the example): Add methods to check the value
=====================
– loanAmount (20%)
– must be a number, threw FormatException if not
– must be greater than 50000, throw Exception if not
– Create a method CheckLoanAmount(double la)
throw new MyRangeException(“Loan Amount must be $50,000 or more.”);
-public static void CheckLoanAmount(double la)
{
if (la < 50000)
throw new MyRangeException( “Loan Amount must be $50,000 or more.”);
}
– loanInterest (20%)
– must be a number, threw FormatException if not
– must be greater than 1%, throw Exception if not
– Create a method CheckLoanInterest(double it)
throw new MyRangeException(“Interest Rate must be 1% or more.”);
– public static void CheckLoanInterest(double it)
{……}
– years (20%)
– must be a number, threw FormatException if not
– must be greater than 5, throgh Exception if not
– Create a method CheckLoanYears(double yr)
throw new MyRangeException(“Years must be 5 years or more.”);
– public static void CheckLoanYears(double yr)
{……}