Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create a java program to interact with the user to gather and display student - related information. You will practice handling user input, performing string

Create a java program to interact with the user to gather and display student-related information. You
will practice handling user input, performing string manipulations, and managing program flow with
conditionals and loops.
Declare Variables:
Inside the main method, start by declaring the variables you will use:
continueRunning (boolean) to control the main loop.
option (int) to store user's menu choice.
studentPhoneNum, FormattedPhoneNum (String) for handling phone numbers.
fname, lname (String) for the student's first and last name.
courseName (String) and studentScore (double) for course details.
Implement the Main Loop:
Use a while loop to keep the program running until the user decides to exit.
Display a menu with options for:
1- Adding or viewing a student's course and grade.
2- Formatting and displaying the student's name.
3- Entering and formatting a students phone number.
4- Exiting the program and display student Information.
Use Scanner to read the users choice and implement the functionality based on the choice.
Implement Menu Options:
Option 1: Student Course and Grade
Prompt the user to enter the course name and the student score.
Display the course and score.
Option 2: Format Student Names
Ask for the student's first and last names(individually).
Convert the names to uppercase and display them.
Display the initials of the student.
Option 3: Enter Student Phone Number
Prompt for a 10-digit phone number.
Format it as XXX-XXX-XXXX and display.
Option 4: Exit
Display all collected information.
Thank the user and prepare to exit the loop.
Error Handling for Menu Selection:
Add an error handling mechanism to the menu selection process:
Inside your main loop, after processing valid options with if and else if statements, use an else statement
to handle any input that does not match a defined option.
Display an error message: Invalid Option Please see the Sample Run
Also, In option 1 and option 2, we might need the buffer clearing, use (input.nextLine()) inside the if, else
if statement.
Loop Control:
After executing any of the options, ask the user if they want to continue.
If the user types "No", set continueRunning to false to exit the loop.
Otherwise, continue with the next iteration.
The loop Control should work with upper and lower case for Yes and No
Documentation and Comments:
Add comments to your code to explain the purpose of each part and how it works.
Ensure your code is readable and well-organized

Step by Step Solution

There are 3 Steps involved in it

Step: 1

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_2

Step: 3

blur-text-image_3

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

SQL Database Programming

Authors: Chris Fehily

1st Edition

1937842312, 978-1937842314

More Books

Students also viewed these Databases questions