Question
//What is wrong with this two files: import java.util.Scanner; public class TestScore1{ public static void main(String[] args) { int test1; int test2; int test3; double
//What is wrong with this two files:
import java.util.Scanner; public class TestScore1{ public static void main(String[] args) { int test1; int test2; int test3; double average; Scanner keyboard = new Scanner(System.in); testScoreAverage = new Average ();
System.out.print("Enter first test score "); testScoreAverage.settest1 = keyboard.nextint(); System.out.print("Enter second test score "); testScoreAverage.settest2 = keyboard.nextint(); System.out.print("Enter third test score "); testScoreAverage.settest3 = keyboard.nextint();
System.out.println("Average score " + getAverage()); } }
//Second one
class Average{ private int test1; private int test2; private int test3; private double average;
public void setTest1(int t1) { test1 = t1; } public void setTest2(int t2) { test2 = t2; } public void setTest3(int t3) { test3 = t3; }
public int getTest1() { return test1; } public int getTest2() { return test2; } public int getTest3() { return test3; }
public double getAverage() { return (test1+test2+test3)/3 ; } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started