I don't really understand how to make the scores show up and how to make it start over. I honestly only half understand the things I've used to piece this together to make this work so far. but this is what I was asked to do.....
and this is what I have so far.......
package speakmanassignment2;
import java.util.*;
public class SpeakmanAssignment2
{
public static void main(String[] args) {
// First & Last Names
String FirstName = getFirstName();
String LastName = getLastName();
Scanner sc = new Scanner(System.in);
int score[]=new int[3];
//Score input
System.out.println("First Score:");
score[0]=sc.nextInt();
System.out.println("Second Score");
score[1]=sc.nextInt();
System.out.println("Third Score");
score[2]=sc.nextInt();
//Total
int total= getTotal(score);
//Average
float average = (float)total/3;
//Calculate grade
char grade = getGrade(average);
//Output
System.out.println("Full name "+FirstName+" "+LastName);
System.out.println("Score 1: %f, Score2:f, Score3:f, ");
System.out.println("Total %.2f"+total);
System.out.printf("Average %.2f ",average);
System.out.println("\n Grade "+grade);
}
//Return first name
public static String getFirstName(){
Scanner sc = new Scanner(System.in);
System.out.println("Enter First Name ");
String name = sc.next();
return name;
}
//Return last name
public static String getLastName(){
Scanner sc = new Scanner(System.in);
System.out.println("Enter Last Name ");
String name = sc.next();
return name;
}
//Return scores
{
}
//Return total score
public static int getTotal(int a[]){
int total=0;
for(int i=0;i<a.length;i++){
total+=a[i];
}
return total;
}
//Return grade
public static char getGrade(float average){
if(average>=90.00 && average<=100.00)
return 'A';
else if(average>=80.00&&average<=89.99)
return 'B';
else if(average>=70.00&&average<=79.99)
return 'C';
else
return 'F';
}
}
------END------
Any help with this would really be appreciated cause I'm really lost.
Ifyou have any doubts, pelase give me comment
import java.util.*;
public class SpeakmanAssignment2 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
char choice;
do{
// First & Last Names
String FirstName = getFirstName();
String LastName = getLastName();
int score[] = new int[3];
// Score input
System.out.println("First Score:");
score[0] = sc.nextInt();
System.out.println("Second Score");
score[1] = sc.nextInt();
System.out.println("Third Score");
score[2] = sc.nextInt();
// Total
int total = getTotal(score);
// Average
float average = (float)total / 3;
// Calculate grade
char grade = getGrade(average);
// Output
System.out.println("Full name " + FirstName + " " + LastName);
System.out.printf("Score 1: %d, Score2: %d, Score3: %d\n", score[0], score[1], score[2]);
System.out.printf("Total %d\n",total);
System.out.printf("Average %.2f\n", average);
System.out.println("Grade " + grade);
System.out.print("\nDo you want enter another(Y/N)?");
choice = sc.next().toLowerCase().charAt(0);
}while(choice=='y');
}
// Return first name
public static String getFirstName() {
Scanner sc = new Scanner(System.in);
System.out.println("Enter First Name ");
String name = sc.next();
return name;
}
// Return last name
public static String getLastName() {
Scanner sc = new Scanner(System.in);
System.out.println("Enter Last Name ");
String name = sc.next();
return name;
}
// Return scores
{}
// Return total score
public static int getTotal(int a[]) {
int total = 0;
for (int i = 0; i < a.length; i++) {
total += a[i];
}
return total;
}
// Return grade
public static char getGrade(float average) {
if (average >= 90.00 && average <= 100.00)
return 'A';
else if (average >= 80.00 && average <= 89.99)
return 'B';
else if (average >= 70.00 && average <= 79.99)
return 'C';
else
return 'F';
}
}
I don't really understand how to make the scores show up and how to make it...
Please make the following code modular. Therefore contained in a package with several classes and not just one. import java.util.*; public class Q { public static LinkedList<String> dogs = new LinkedList<String> (); public static LinkedList<String> cats = new LinkedList<String> (); public static LinkedList<String> animals = new LinkedList<String> (); public static void enqueueCats(){ System.out.println("Enter name"); Scanner sc=new Scanner(System.in); String name = sc.next(); cats.addLast(name); animals.addLast(name); } ...
Step 4: Add code that discards any extra entries at the propmt that asks if you want to enter another score. Notes from professor: For Step 4, add a loop that will validate the response for the prompt question: "Enter another test score? (y/n): " This loop must only accept the single letters of ‘y’ or ‘n’ (upper case is okay). I suggest that you put this loop inside the loop that already determines if the program should collect...
Hello, How can I make the program print out "Invalid data!!" and nothing else if the file has a grade that is not an A, B, C, D, E, or F or a percentage below zero? I need this done by tomorrow if possible please. The program should sort a file containing data about students like this for five columns: one for last name, one for first name, one for student ID, one for student grade percentage, one for student...
This is not my entire line of code but the errors I'm getting are from this section. Can you please correct it and tell me where I went wrong? Thank you! package comJava; Vimport java.time.LocalDate; import java.util.ArrayList; import java.util.List; import java.util.Scanner; //Lis public Driver { static List<RescueAnimal> list = new ArrayList<>(); public static void main(String[] args) { // Class variables // Create New Dog Dog d = new Dog(); // Create New Monkey Monkey m = new Monkey(); // Method...
I have this program that works but not for the correct input file. I need the program to detect the commas Input looks like: first_name,last_name,grade1,grade2,grade3,grade4,grade5 Dylan,Kelly,97,99,95,88,94 Tom,Brady,100,90,54,91,77 Adam,Sandler,90,87,78,66,55 Michael,Jordan,80,95,100,89,79 Elon,Musk,80,58,76,100,95 output needs to look like: Tom Brady -------------------------- Assignment 1: A Assignment 2: A Assignment 3: E Assignment 4: A Assignment 5: C Final Grade: 82.4 = B The current program: import java.io.File; import java.io.FileNotFoundException; import java.io.FileWriter; import java.io.IOException; import java.util.Scanner; public class main { public static void main(String[]...
Please put both of this loops into one program. Set it up so that there is one main function and both loops are within it. Thank You. import java.util.Scanner; public class WhileDavidMungomaLab12 { public static void main(String[] args) { int aScore = -1; while (aScore < 0 || aScore > 100) { Scanner sc = new Scanner(System.in); System.out.println("Please enter a valid number that is within the specified range(0 and 100): "); aScore = sc.nextInt(); } } } AND import java.util.Scanner;...
I keep getting an Error after I ask the user for test scores. What is missing? package testscores; import java.util.Scanner; public class TestScores { /** * @param args the command line arguments */ private double[] scores; public TestScores(double[] score) throws IllegalArgumentException { scores = new double[scores.length]; for (int i = 0; i < scores.length; i++) { if (score[i] < 0 || score[i] > 100){ throw new IllegalArgumentException(); } scores[i]=score[i]; } } public double getAverage() { int sum=0;...
package rectangle; public class Rectangle { private int height; private int width; public Rectangle(int aHeight, int aWidth) { super(); height = aHeight; width = aWidth; } public int getHeight() { return height; } public int getWidth() { return width; } public void setHeight(int aHeight) { height = aHeight; } public void setWidth(int aWidth) { width = aWidth; } public int...
java create java class "nameperson" the example of output would be this: //if the user inputs sophia 206999109 2 //then the output shows this My name is None and my studentid is 0 My name is sophia and studentid is 0 My name is sophia and studentid is 206999109 My grade is 2 so i have to create two classes class nameperson{ } class studentid extends person{ } class grade extends studentid{ } my main method is this class Main...
I was wanting to know how would I call my add class through my if statement. Here is my class: import java.util.Scanner; public class Main { public static void main(String[] args) { int num1 = 0; int num2 = 0; int answer = 0; int userInput = 0; Scanner sc = new Scanner(System.in); System.out.println("Hello, this is a program where you can choose...