7 Replies - 534 Views - Last Post: 19 March 2012 - 06:00 PM Rate Topic: -----

#1 ticomario  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 22-February 12

my lab is test average and grade.

Posted 19 March 2012 - 02:10 PM

import java.util.Scanner;

/**
	This Program will ask the user to enter five scores. Than it will display a letter grade for each score and the average score.
	Lab 5 page 291 problem 7

	This was written by Mario 
*/

public class MVAverage&Grade
{//begin class

	public static void main (String[]args)
	{//begin main method

	Scanner keyboard = new Scanner(System.in);

	    double testScore1;

	    double testScore2;

	    double testScore3;

	    double testScore4;

		double testScore5;

     	System.out.print("Enter your first test score: ");

	    testScore1 = keyboard.nextInt();

	    System.out.print("Enter your second test score: ");

	    testScore2 = keyboard.nextInt();

	    System.out.print("Enter your third test score: ");

	    testScore3 = keyboard.nextInt();

	    System.out.print("Enter your fourth test score: ");

	    testScore4 = keyboard.nextInt();

	    System.out.print("Enter your fifth test score: ");

	    testScore5 = keyboard.nextInt();

	    keyboard.nextLine();

	    double average = calcAverage(testScore1,testScore2, testScore3, testScore4, testScore5);

	    System.out.println("The average is: ");

	    determineGrade(average);

	    }
		public static double calcAverage(int testScore1, int testScore2, int testScore3, int testScore4, int testScore5)

	    {

	    double average = (testScore1 + testScore2 + testScore3 + testScore4 + testScore5) / 5;

	     return average
		}

		public static void double determineGrade(double average);


	    {

	    if (average>90)

	    {

	    System.out.println("You got an A");

	    }

	    else if (average>=80)

	    {

	    System.out.println("You got a B");

	    }

	     else if (average>=70)

	    {

	    System.out.println("You got a C");

	    }

	    else if (average>=60)

	    {

	    System.out.println("You got a D");

	    }

	    else if (average<60)

	    {

	    System.out.println("You got an F");

	    System.out.println("The average is: " + average);

}//end class

	}//end main method




import java.util.Scanner;

/**
	This Program will ask the user to enter five scores. Than it will display a letter grade for each score and the average score.
	Lab 5 page 291 problem 7

	This was written by Mario Valverde

*/

public class MVAverage&Grade
{//begin class

	public static void main (String[]args)
	{//begin main method

	Scanner keyboard = new Scanner(System.in);

	    double testScore1;

	    double testScore2;

	    double testScore3;

	    double testScore4;

		double testScore5;

     	System.out.print("Enter your first test score: ");

	    testScore1 = keyboard.nextInt();

	    System.out.print("Enter your second test score: ");

	    testScore2 = keyboard.nextInt();

	    System.out.print("Enter your third test score: ");

	    testScore3 = keyboard.nextInt();

	    System.out.print("Enter your fourth test score: ");

	    testScore4 = keyboard.nextInt();

	    System.out.print("Enter your fifth test score: ");

	    testScore5 = keyboard.nextInt();

	    keyboard.nextLine();

	    double average = calcAverage(testScore1,testScore2, testScore3, testScore4, testScore5);

	    System.out.println("The average is: ");

	    determineGrade(average);

	    }
		public static double calcAverage(int testScore1, int testScore2, int testScore3, int testScore4, int testScore5)

	    {

	    double average = (testScore1 + testScore2 + testScore3 + testScore4 + testScore5) / 5;

	     return average
		}

		public static void double determineGrade(double average);


	    {

	    if (average>90)

	    {

	    System.out.println("You got an A");

	    }

	    else if (average>=80)

	    {

	    System.out.println("You got a B");

	    }

	     else if (average>=70)

	    {

	    System.out.println("You got a C");

	    }

	    else if (average>=60)

	    {

	    System.out.println("You got a D");

	    }

	    else if (average<60)

	    {

	    System.out.println("You got an F");

	    System.out.println("The average is: " + average);

}//end class

	}//end main method


I COMPILED THE PROGRAM BUT I HAVE SIX ERRORS CAN YOU POINT OUT TO ME WHERE I WENT WRONG.

This post has been edited by pbl: 19 March 2012 - 05:53 PM
Reason for edit:: Please use code tags


Is This A Good Question/Topic? 0
  • +

Replies To: my lab is test average and grade.

#2 GregBrannon  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1978
  • View blog
  • Posts: 4,822
  • Joined: 10-September 10

Re: my lab is test average and grade.

Posted 19 March 2012 - 02:11 PM

Post your code in code tags. Post your errors, copied and pasted.
Was This Post Helpful? 0
  • +
  • -

#3 ticomario  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 22-February 12

Re: my lab is test average and grade.

Posted 19 March 2012 - 02:14 PM

E:\Java Programs\MVAverage&Grade.java:11: '{' expected
public class MVAverage&Grade
^
E:\Java Programs\MVAverage&Grade.java:64: ';' expected
return average
^
E:\Java Programs\MVAverage&Grade.java:67: <identifier> expected
public static void double determineGrade(double average);
^
E:\Java Programs\MVAverage&Grade.java:67: '(' expected
public static void double determineGrade(double average);
^
E:\Java Programs\MVAverage&Grade.java:67: invalid method declaration; return type required
public static void double determineGrade(double average);
^
E:\Java Programs\MVAverage&Grade.java:114: reached end of file while parsing
}//end main method
^
6 errors

Tool completed with exit code 1
Was This Post Helpful? 0
  • +
  • -

#4 codeofc  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 44
  • Joined: 05-November 11

Re: my lab is test average and grade.

Posted 19 March 2012 - 02:18 PM

Change nextInt to nextDouble
Was This Post Helpful? 0
  • +
  • -

#5 ticomario  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 22-February 12

Re: my lab is test average and grade.

Posted 19 March 2012 - 02:21 PM

i still get the same errors is there anything else wrong with my program besides that.
Was This Post Helpful? 0
  • +
  • -

#6 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8020
  • View blog
  • Posts: 31,127
  • Joined: 06-March 08

Re: my lab is test average and grade.

Posted 19 March 2012 - 03:28 PM

Looks like the same homework :)

http://www.dreaminco...1&#entry1580339
Was This Post Helpful? 0
  • +
  • -

#7 ticomario  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 22-February 12

Re: my lab is test average and grade.

Posted 19 March 2012 - 04:57 PM

well im just working with what my professor assigned in the java book i have for college and had a friend help me out with the program but we ran out of time .
Was This Post Helpful? 0
  • +
  • -

#8 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8020
  • View blog
  • Posts: 31,127
  • Joined: 06-March 08

Re: my lab is test average and grade.

Posted 19 March 2012 - 06:00 PM

You can't have a "&" in a class name

http://docs.oracle.c...html/index.html

and avoid useless blank lines. Ideally a whole method should be shown on your editor, with all these blank line you will seriously reduce the number of lines your methods can have.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1