Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Open a new project in NetBeans with the title YourLast Name First initialLab4. (Ex: If your name is Cocoa Butter, your project name

image text in transcribed image text in transcribed 

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)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

Here is the completed code YourLastNameFirstInitialLab4java java import javautilScanner public class ... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advanced Accounting

Authors: Floyd A. Beams, Joseph H. Anthony, Bruce Bettinghaus, Kenneth Smith

11th Edition

978-0132568968, 9780132568968

More Books

Students also viewed these Accounting questions