Friday, June 13, 2008

INTPROG ENTRY 2

user input program.

import java.util.*;
public class QuizAverage
{
public static void main (String[] args)
{
double dGrade1, dGrade2, dGrade3, dFinal;
System.out.println("Compute Quiz Average!");
System.out.print("Input 1st Score here:");
Scanner sc = new Scanner (system.in);
dGrade1 = sc.nextDouble();
System.out.print("Input 2nd Score here:");
Scanner sc = new Scanner (system.in);
dGrade2 = sc.nextDouble();
System.out.print("Input 3rd Score here:");
Scanner sc = new Scanner (system.in);
dGrade3 = sc.nextDouble();
dFinal = (dGrade1 + dGrade2 + dGrade3) / 3;
System.out.println("Quiz Average:" + dFinal);
sc.close();
{
{

Output:
Compute Quiz Average!
Input 1st Score here: //user inputs 1st score here
Input 2nd Score here: //user inputs 2nd score here
Input 3rd Score here: //user inputs 3rd score here
Quiz Average: //shown here is the average of 3 scores

No comments: