Summary of Coding Notes
Summary of Coding Notes
▪ Data Types
String friend1;
Int age;
Concole.writeline(“Name/tAge”);
Console.writeline(“====/t====”);
Console.writeline(“{0}/t{1}”,friend1,age);
• Skipping lines:
Console.writeline(“Proudly/nSouth/nAfrican”);
• Console.Clear();
Trace Tables
▪ Trace tables - can be used to test an algorithm to make sure that the algorithm is free of
logical errors.
▪ Use a trace table to determine what the values of a, b, and c will be once the code below has
been executed.
int a = 10, b = 5, c = 3; a b c
a = b + c * 2;
b = b + (10 - c);
10 5 3
c = b + b;
11 12 24
▪ Write a program that accepts a number of hours (hoursWorked) and rate of pay (rateOfPay)
as input, and displays the employee wage.
// calculation
wage = hoursWorked * rateOfPay;
// display output
Console.WriteLine();
Console.WriteLine("Employee Wage: {0:c}", wage);
// calculation
percWon = gamesWon / (double)(gamesWon + gamesLost) * 100;
// display output
Console.WriteLine("{0} won {1} percent of its games", teamName, percWon);
Console.ReadLine();
}