1. Open a new project in NetBeans with the title YourLast Name First initialLab4. (Ex: If...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
1. Open a new project in NetBeans with the title YourLast Name First initialLab4. (Ex: If your name is Cocoa Butter, your project name would be ButterCLab4.) 2. Add the necessary import statement for the Scanner class. Program (10 pts): Your task is to write four static methods that, when used with the given main method code, will result in the outputs provided below. In order to test your program you should copy and paste the following code exactly into the main method in your project: //Initialize variables Scanner kbd-new Scanner(System.in); String fName, IName, fullName; int birthYear, age; double gpa1, gpa2, gpa3, avgGPA; final int CURRENT YEAR = 2018; #Collect info from user System.out.print("What is your first name? "}; fName - kbd.next(); System.out.print("What is your last name?"); IName - kbd.next(); System.out.print("What year were you born? "); birthYear = kbd.nextInt(); System.out.print("Enter first GPA: "); gpa1 kbd.nextDouble(); System.out.print("Enter second GPA: "); gpa2 kbd.nextDouble(); System.out.print("Enter third GPA: "); gpa3 kbd.nextDouble(); #Call methods fullName = fullName(fName, IName); age = ageCalc(birthYear, CURRENT YEAR); avgGPA = gpaCalc(gpa1, gpa2, gpa3); printInfo(fullName, age, avgGPA); NetBeans will give you all sorts of red lines at first, because the methods called in the code are not written yet. Your job is to write these four static methods, described below: 1. A method called fullName that takes the user's first name and last name as parameters, and returns a single String in the form "LastName, FirstName". 2. A method called ageCalc that takes the user's birth year and the current year as parameters, then calculates and returns the user's age as an integer. 3. A method called gpaCaic that takes three GPA's as parameters, then calculates and returns the average GPA as a double. 4. A method called printinfo that takes the user's full name as a String, age as an integer, and GPA as a double. This method will display the user's info to the screen as shown in the sample outputs. Note: the GPA should show two digits after the decimal only. Tips: ⚫ Do not change or add to the provided main method code. The program should match the sample outputs when executed with your own methods inserted, and the main method as-is. ⚫ Make sure your static methods are inside of your main class, but outside of the main method. • You may want to test each of your methods inside of a different, test project, then paste them into your Lab 4 project when ready. This might be easier than trying to run the full provided program every time you want to test something. Sample Output #1: Output - Lab4F18 (run) X run: D D What is your first name? Homer What is your last name? Simpson What year were you born? 1989. Enter first GPA: 3.45 Enter second GPA: 2.7 Enter third GPA: 3.89 Name: Simpson, Homer Age: 29 years Cumulative GPA: 3.35 BUILD SUCCESSFUL (total time: 15 seconds) Sample Output #2: D Output - Lab4F18 (run) x run: What is your first name? Molly What is your last name? Ringwald What year were you born? 1968. Enter first GPA: 4.0 Enter second GPA: 3.56 Enter third GPA: 3.79 Name: Ringwald, Molly Age: 50 years Cumulative GPA: 3.78 BUILD SUCCESSFUL (total time: 52 seconds) 1. Open a new project in NetBeans with the title YourLast Name First initialLab4. (Ex: If your name is Cocoa Butter, your project name would be ButterCLab4.) 2. Add the necessary import statement for the Scanner class. Program (10 pts): Your task is to write four static methods that, when used with the given main method code, will result in the outputs provided below. In order to test your program you should copy and paste the following code exactly into the main method in your project: //Initialize variables Scanner kbd-new Scanner(System.in); String fName, IName, fullName; int birthYear, age; double gpa1, gpa2, gpa3, avgGPA; final int CURRENT YEAR = 2018; #Collect info from user System.out.print("What is your first name? "}; fName - kbd.next(); System.out.print("What is your last name?"); IName - kbd.next(); System.out.print("What year were you born? "); birthYear = kbd.nextInt(); System.out.print("Enter first GPA: "); gpa1 kbd.nextDouble(); System.out.print("Enter second GPA: "); gpa2 kbd.nextDouble(); System.out.print("Enter third GPA: "); gpa3 kbd.nextDouble(); #Call methods fullName = fullName(fName, IName); age = ageCalc(birthYear, CURRENT YEAR); avgGPA = gpaCalc(gpa1, gpa2, gpa3); printInfo(fullName, age, avgGPA); NetBeans will give you all sorts of red lines at first, because the methods called in the code are not written yet. Your job is to write these four static methods, described below: 1. A method called fullName that takes the user's first name and last name as parameters, and returns a single String in the form "LastName, FirstName". 2. A method called ageCalc that takes the user's birth year and the current year as parameters, then calculates and returns the user's age as an integer. 3. A method called gpaCaic that takes three GPA's as parameters, then calculates and returns the average GPA as a double. 4. A method called printinfo that takes the user's full name as a String, age as an integer, and GPA as a double. This method will display the user's info to the screen as shown in the sample outputs. Note: the GPA should show two digits after the decimal only. Tips: ⚫ Do not change or add to the provided main method code. The program should match the sample outputs when executed with your own methods inserted, and the main method as-is. ⚫ Make sure your static methods are inside of your main class, but outside of the main method. • You may want to test each of your methods inside of a different, test project, then paste them into your Lab 4 project when ready. This might be easier than trying to run the full provided program every time you want to test something. Sample Output #1: Output - Lab4F18 (run) X run: D D What is your first name? Homer What is your last name? Simpson What year were you born? 1989. Enter first GPA: 3.45 Enter second GPA: 2.7 Enter third GPA: 3.89 Name: Simpson, Homer Age: 29 years Cumulative GPA: 3.35 BUILD SUCCESSFUL (total time: 15 seconds) Sample Output #2: D Output - Lab4F18 (run) x run: What is your first name? Molly What is your last name? Ringwald What year were you born? 1968. Enter first GPA: 4.0 Enter second GPA: 3.56 Enter third GPA: 3.79 Name: Ringwald, Molly Age: 50 years Cumulative GPA: 3.78 BUILD SUCCESSFUL (total time: 52 seconds)
Expert Answer:
Posted Date:
Students also viewed these accounting questions
-
The Wall Street Journal reports that the current rate on 10-year Treasury bonds is 7.50 percent, on 20-year Treasury bonds is 8.10. percent, and on a 20-year corporate bond issued by MHM Corporation...
-
For how long can you withdraw at the beginning of each month $500 from a fund of $100,000 if interest is 5% compounded monthly? Provide an answer in years. (Round your final answer to 2 decimals).
-
CANMNMM January of this year. (a) Each item will be held in a record. Describe all the data structures that must refer to these records to implement the required functionality. Describe all the...
-
Over the past 10 years, a bank has experienced the following loan losses on its C&I loans, consumer loans, and total loan portfolio. Using regression analysis on these historical loan losses, the...
-
Give several reasons why a conductor would not be a good choice as a dielectric for a capacitor.
-
What happens to the curves as the degrees of freedom for the numerator and the denominator get larger?
-
The following information is available to reconcile Branch Companys book balance of cash with its bank statement cash balance as of July 31, 2008. a. After all posting is complete on July 31, the...
-
An array of electronic chips is mounted within a sealed rectangular enclosure, and cooling is implemented by attaching an aluminum heat sink (k = 180 W/m K). The base of the heat sink has dimensions...
-
What factors contribute to student success in online learning environments?" , your unit of analysis could be individual students. Independent variable: a. What is your independent variable (IV)? b....
-
Asymmetrical-attenuator pad has a series arm of 500 12 resistance and each shunt arm of 1 k2 resistance. Determine (a) the characteristic impedance and (b) the attenuation (in dB) produced by the pad.
-
True or False. The fundamental frequency given by Rayleigh's method will always be larger than the exact value.
-
What is a rotation matrix? What is its purpose in Jacobi's method?
-
What is meant by the term audit samplmgl
-
True or False. Rayleigh's method can be considered to be same as the conservation of energy for a vibrating system.
-
Fill in the Blank. The computation of higher natural frequencies, based on the matrix iteration method, involves a process known as matrix ___________ .
-
Prepare a master budget for McGregor Pharmacy Company for the year ending December 31, 2021 using the following information. Prepare it per quarter. Use the tables provided by the professor. Fill it....
-
Open Text Corporation provides a suite of business information software products. Exhibit 10-9 contains Note 10 from the companys 2013 annual report detailing long-term debt. Required: a. Open Text...
-
Use the plant asset records from On Your Own 8-2. The following transactions occurred in 20X5. A general journal, cash receipts journal, and plant asset records are provided in the Working Papers....
-
Dependable Deliveries, Inc., has real property with an assessed value of $350,000.00. The annual tax rate in the city where the property is located is 4.5% of assessed value. Half of the annual tax...
-
Use the plant asset record from Application Problem 8-1. Using the straight-line method, complete a depreciation table for each of the plant assets bought by Mannings, Inc. Data from Problem 8-1...
![Mobile App Logo](https://dsd5zvtm8ll6.cloudfront.net/includes/images/mobile/finalLogo.png)
Study smarter with the SolutionInn App