question archive Modify the program you created above (Hello_Ashford) to add three test scores and find the average

Modify the program you created above (Hello_Ashford) to add three test scores and find the average

Subject:Computer SciencePrice:3.87 Bought7

Modify the program you created above (Hello_Ashford) to add three test scores and find the average. Use the PRINTLN to display your name, the scores and average.

Review

Primitive Data Type

  • byte (number, 1 byte)
  • short (number, 2 bytes)
  • int (number, 4 bytes)
  • long (number, 8 bytes)
  • float (float number, 4 bytes)
  • double (float number, 8 bytes)
  • char (a character, 2 bytes)
  • boolean (true or false, 1 byte)

Week1 Lab1 Simple JAVA Program

Delete System.out.println( "Hello Ashford Student.....")

Replace with:

String name = "enter your name here";

double Score1 = enter a test score between 1 and 100 here;

double Score2 = enter a test score between 1 and 100 here;

double Score3 = enter a test score between 1 and 100 here;

double Average = ( Score1 + Score2 + Score3)/3;

//now you are ready to print

System.out.println (name);

System.out.println (Score1);

System.out.println (Score2);

System.out.println (Score3);

System.out.println (Average);

 

pur-new-sol

Purchase A New Answer

Custom new solution created by our subject matter experts

GET A QUOTE

Answer Preview

Answer:
import java.util.*;
class Week1Lab1
{
    //main method
	public static void main(String[] args) 
	{
		Scanner sc=new Scanner(System.in);
	
		String name;
      
        //Enter name
		System.out.print("enter your name: ");
		name=sc.nextLine();
		
	double Score1;
		double Score2;
		double Score3;
        //Enter score1  score2  and score3
		System.out.print("enter a test score between 1 and 100: ");
		Score1=sc.nextDouble();
		System.out.print("enter a test score between 1 and 100: ");
		Score2=sc.nextDouble();
		System.out.print("enter a test score between 1 and 100: ");
		Score3=sc.nextDouble();
		double Average = ( Score1 + Score2 + Score3)/3;
		System.out.println (name);
		System.out.println (Score1);
		System.out.println (Score2);
		System.out.println (Score3);
		System.out.println (Average);
}
		
}

PFA