CSC 120: Introduction to Programming Methodology. Programming Lab. 1.
Define a class (name it TestSwitchDriver). 2. Add to the class, two static integral ...
CSC 120: Introduction to Programming Methodology Programming Lab 1. Define a class (name it TestSwitchDriver). 2. Add to the class, two static integral variables (name them aInt and bInt) and one static character variable (name it aChar). 3. Add to the class, a static method (name stateClassification). The method would accept as an argument ( or parameter), a character value and would do the following, using the switch…case statement: a. Print to the screen, Your classification is freshman, if the argument is ‘f’ or ‘F’. b. Print to the screen, Your classification is sophomore, if the argument is ‘p’ or ‘P’. c. Print to the screen, Your classification is junior, if the argument is ‘j’ or ‘J’. d. Print to the screen, Your classification is senior, if the argument is ‘s’ or ‘S’ e. Print to the screen, Your classification cannot be determined, if the argument is not any of the characters mentioned in (a)-(d). 4. Add to the main method to the class. Within the method, a. declare a BufferedReader object (name it stdInput), and tie it the System.in object.. b. Write a statement to prompt the user to enter a character. c. Initialize aChar to the character read from the keyboard using the stdInput. d. call the stateClassification method with aChar as the argument, 5. Save your program to the file TestSwitchDriver.java. Compile and run the program, making sure the program is free of errors. 6. Add to the program, a static method (name it stateMajor). ). The method would accept as an argument ( or parameter), an integral and would do the following, using the switch…case statement: a. Print to the screen, Your major is Mathematics, if the argument is 0. b. Print to the screen, Your major is Computer Science, if the argument is 1. c. Print to the screen, Your major is Chemistry, if the argument is 2. d. Print to the screen, Your major is Biology, if the argument is 3. e. Print to the screen, Your major is Business Administration, if the argument is 4. f. Print to the screen, Your major is Marketing, if the argument is 5. g. Print to the screen, Your major is Accounting, if the argument is 6. h. Print to the screen, Your major is History, if the argument is 7. i. Print to the screen, Your major cannot be determined, if the argument is not any of the integers mentioned in (a)-(h). 7. Add to the main method, a. a statement to prompt the user to enter an integer. b. Initialize aInt to the integer read from the keyboard using the stdInput.
c. call stateMajor method with aInt as the argument. 8. Save your changes, compile and run the program. 9. Add to the program, a static method (name it stateCollege). ). The method would accept as an argument ( or parameter), an integral and would do the following, using the switch…case statement: a. Print to the screen, Your from College of Basics and Applied Sciences, if the argument is 0. b. Print to the screen, Your from College of Engineering, if the argument is 1. c. Print to the screen, Your from College of Arts and Humanities, if the argument is 2. d. Print to the screen, Your College of Business, if the argument is 3. e. Print to the screen, Your college cannot be determined, if the argument is not any of the integers mentioned in (a)-(d). 10. Add to the main method, a. a statement to prompt the user to enter an integer. b. Initialize bInt to the integer read from the keyboard using the stdInput. c. call stateCollege method with bInt as the argument. 11. Repeat (8). 12. Submit a hardcopy of your program.