Professional Documents
Culture Documents
CPSC6548 FA21 LabAssignment#5Soln
CPSC6548 FA21 LabAssignment#5Soln
A Multiplication Table method called void table(int, int) which takes as parameters, rows and
columns, nicely formatted with headings, using printf().
Code
Output
b. Overload the void table(double, int) function and create an Exponentiation Table which takes as
parameters, rows and columns (which would be the base and exponent).
Code
OUTPUT
c. You can have the table() function call other functions which you create called multiply(n, n) or
power(n, e)
CODE
d. A member method called void primes(void) which generates the first 10 prime numbers, nicely
formatted using printf().
CODE
OUTPUT
e. An overload of primes called void primes(int) which accepts a value inputted from the user in
main() (up to 50) and generates that number of primes, nicely formatted with printf()
CODE
OUTPUT
f. A method called void circle(void) which prompts the user for the radius and displays the area
and circumference of a circle.
CODE
OUTPUT
g. A method called double stats(int n) which prompts the user to enter n (1-10) values and returns
the mean (average) of the values.
CODE
OUTPUT
h. An overload of stats() called void stats() which generates 10 random numbers and displays the
mean and sum of the values.
CODE
OUTPUT
i. A method called void ascii() which takes the start and end values validated in main() and
generates a table.
CODE
OUTPUT
Main.java
package com.sanj;
switch (userChoice){
case "1":
prepareMultiplicationTable(calcEngine);
break;
case "2":
prepareExponentialTable(calcEngine);
break;
case "3":
calcEngine.primes();
break;
case "4":
inputPrimeNumbersLimit(calcEngine);
break;
case "5":
calcEngine.circle();
break;
case "6":
inputLimitOfStats(calcEngine);
break;
case "7":
calcEngine.stats();
break;
case "8":
prepareAsciiTable(calcEngine);
break;
case "9":
conversionMenu(calcEngine);
break;
default:
calcEngine.conversion(userChoice);
break;
}
}