Question

In: Computer Science

Modify the Assignment program from Module 1 to read a user's first and last name read...

Modify the Assignment program from Module 1 to read a user's first and last name read three integer scores, calculate the total and average determine the letter grade based on the following criteria - Average 90-100 grade is A, 80-89.99 grade is B, 70-79.99 grade is C, all others F (use a nested if) Output formatted results consisting of the full name, the three scores, the total, average (to 2 decimal places), and the letter grade go to step 1 if user wants to go through the above 4 steps for another student You are required to use a method for each of the steps 1-4 . This program DOES NOT involve creating a class as covered in chapter 3.

Hint: you are required to use a while loop and a nested if in this program in addition to working with methods. Method main will mainly have declarations and calls to these methods. You may call a method multiple times Include a pledge that the programs were entirely your work and specify the IDE used to write these programs

write a headerMethod to output the descriptive header
Write one nameMethod and call it twice (value returning)
write one scoresMethod and call it three times
a value returning method to retun the total
a value returning method to return the average
a value returning method to return the letterGrade
an outputMethod to output formatted results (first and last name, the 3 scores,
total average, and letter grade


Please you use java code. And it keep simple, because its an intro crouses

Solutions

Expert Solution

Code


import java.util.Scanner;

public class Student {
static Scanner scnr=new Scanner(System.in);
public static void main(String[] args) {
String first_name,last_name;
int score1,score2,score3,total;
double avg;
char again='y',letterGrade;
  
while(again=='y')
{
first_name=nameMethod ("Enter first name: ");
last_name=nameMethod ("Enter last name: ");
score1=scoresMethod(1);
score2=scoresMethod(2);
score3=scoresMethod(3);
total=getTotal(score1,score2,score3);
avg=getAverage(total);
letterGrade=getLatterGrade(avg);
outputMethod(first_name,last_name,score1,score2,score3,avg,letterGrade);
System.out.print("\nDo you want to do for another student? (y/n): ");
again=scnr.next().charAt(0);
System.out.println();
}
  
}

private static String nameMethod(String msg) {
System.out.print(msg);
return scnr.next();
}

private static int scoresMethod(int i) {
System.out.print("Enter score "+i+": ");
return scnr.nextInt();
}

private static int getTotal(int score1, int score2, int score3) {
return score1+score2+score3;
}

private static double getAverage(int total) {
return total/3.0;
}

private static char getLatterGrade(double avg) {
if(avg>=90.00)
return 'A';
else if(avg>=80.00)
return 'B';
else if(avg>=70.00)
return 'C';
else if(avg>=60.00)
return 'D';
return 'D';
}

private static void outputMethod(String first_name, String last_name, int score1, int score2, int score3, double avg, char letterGrade) {
String fullname=first_name+" "+last_name;
String format = "%1$-15s%2$-10d%3$-10d%4$-10d%5$-10.2f%6$-10s\n";
String format1 = "\n%1$-15s%2$-10s%3$-10s%4$-10s%5$-10s%6$-10s\n";
System.out.format(format1,"Name","Score1","Score2","Score3","Average","Letter Grade");
System.out.format(format,fullname,score1,score2,score3,avg,letterGrade+"");
}
  
  
}

output

If you have any query regarding the code please ask me in the comment i am here for help you. Please do not direct thumbs down just ask if you have any query. And if you like my work then please appreciates with up vote. Thank You.


Related Solutions

C++ Read first a user's given name followed by the user's age from standard input. Then...
C++ Read first a user's given name followed by the user's age from standard input. Then use an ofstream object named outdata (which you must declare) to write this information separated by a space into a file called outdata. Assume that this is the extent of the output that this program will do. Declare any variables that you need.
PYTHON Modify the program in section Ask the user for a first name and a last...
PYTHON Modify the program in section Ask the user for a first name and a last name of several people.  Use a loop to ask for user input of each person’s first and last names  Each time through the loop, use a dictionary to store the first and last names of that person  Add that dictionary to a list to create a master list of the names  Example dictionary: aDict = { "fname":"Douglas", "name":"Lee" } ...
You are to modify your payroll program from the last assignment to take the new copy...
You are to modify your payroll program from the last assignment to take the new copy of the payroll file called DeweyCheatemAndHow.txt which has the fields separated by a comma to use as input to your program and produce a file that lists all the salaried employee and their gross pay, then each hourly employee and their gross pay and finally each piece rate employee and their gross pay . You are to process all the entries provided in the...
Name the script thirsty.sh. Ask the user if they are thirsty. Read the user's response. If...
Name the script thirsty.sh. Ask the user if they are thirsty. Read the user's response. If they answer no or No, print an appropriate message and exit. If they answer yes or Yes, ask what they would like to drink. Read the user's response. If they answer water print "Clear crisp and refreshing." If they answer beer print "Let me see some id." If they answer wine print "one box or two." If they answer anything else print "Coming right...
Write a Python program that has the user enter their name.   Using the user's name calculate...
Write a Python program that has the user enter their name.   Using the user's name calculate the following: 1. How many letters are in the user's name? 2. Print the user's name in REVERSE both in capital letters and lowercase letters 3. Print the ASCII value for each letter of the user's name. 4. Print the SUM of all of the letters of the user's name (add each letter from #3)
C++ : Write a program that creates a login name for a user, given the user's...
C++ : Write a program that creates a login name for a user, given the user's first name, last name, and a four-digit integer as input. Output the login name, which is made up of the first five letters of the last name, followed by the first letter of the first name, and then the last two digits of the number (use the % operator). If the last name has less than five letters, then use all letters of the...
C++ Write a program that asks a teacher to input a student’s first name, last name,...
C++ Write a program that asks a teacher to input a student’s first name, last name, and four test scores. The program should find the average of the four test scores and should then write the following information to a file named “students.txt” last_name first_name average A student's first name of “XX” should be used as a sentinel value and no numeric grades less than 0 or greater than 100 should be accepted.  The program should then read the information in...
C++ Change the program to take user input for first name and last name for five...
C++ Change the program to take user input for first name and last name for five employees. Add a loop to read the first name and last name. // EmployeeStatic.cpp : Defines the entry point for the console application. // #include "stdafx.h" #include <string> #include <iostream> #include <string> using namespace std; class Employee { public:    Employee(const std::string&, const std::string&); // constructor    ~Employee(); // destructor    std::string getFirstName() const; // return first name    std::string getLastName() const; // return...
Write a program that utilizes a Professor class. A professor has a first name, last name,...
Write a program that utilizes a Professor class. A professor has a first name, last name, affiliation, easiness grade, and a helpfulness grade. Grades range from 1 (lowest) to 5 (highest). The Professor class has two constructors. The first constructor initiates the object with just the first name, the last name, and the affiliation. The default value for easiness and helpfulness grade is 3. The second constructor initiates the object using the first name, the last name, the affiliation, and...
Write a C++ Program to print the first letter of your first and last name using...
Write a C++ Program to print the first letter of your first and last name using stars. Note: 1) Using nested For Loop 2) The number of lines is given by user. 3) Using one Outer loop to print your letters. 4) Print the letters beside each other.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT