C:\Users\Charles Broderick\Documents\M3_Assignments (1).docx
CS 212 Assignment 3 1. Write a user-defined class, Sphere, which includes one instance variable, radius, and following instance methods, set, area, volume and writeOutput. Then write the driver code to use the Sphere class. Requirements, in the driver, prompt a message and let the user input the radius, and then output its surface area and volume to the monitor by calling the writeOutput method, display the results to one decimal place. Use a loop in the driver, so the process could go continuously. 2. Write a user defined class, Programmer, which includes instance variables, name and workingYears, and following instance methods, set, salary and writeOuput. Assume that the salary (S) will increase $3000 per year (Y) of work, plus a base of $42,000, meaning, S = 42000+3000*Y. Then write a driver class to use the Programmer class, prompting a message for the user to keyboard-input the information of a programmer, and output his/her name and salary to the monitor by invoking the writeOuput method. Use a loop in the driver, so the process could go continuously. 3. Write a user-defined class, Student, which includes three instance variables, name, test1 and test2, constructor(s), as well as instance methods, including set, average, grade and writeOutput. Write the driver code to use the Student class, prompting a message for the user to keyboard-input the name and two test scores of a student, and output that student’s information including name, average and grade (“A”, “B”, .., “F”) to the monitor by invoking the writeOuput method. Use a loop in the driver, so the process could go continuously. Page 1 of 1 Page 2 of 1