Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Hi , below i have a program and a class to i need to import icon and JOptionPane please read the promts in the picture
Hi below i have a program and a class to i need to import icon and JOptionPane please read the promts in the picture thanks!
import java.util.Scanner;
public class PetFoodArrow
public static void mainString args
String input ;
char foodGrade ;
foodGrade getInput;
whilefoodGrade X
input getGradefoodGrade;
prinoutfoodGrade input;
foodGrade getInput;
input
End of the program!
;
prinoutfoodGrade input;
Methods' Definitions
public static char getInput
String mssgs "Our pet food is available in grades A B and C
"Which do you want pricing for? X to stop: ;
Scanner keyboard new ScannerSystemin;
System.out.printmssgschar mssgs;
return keyboard.nextLinetoUpperCasecharAt;
public static String getGradechar fudGrade
String iO ;
String messash
Food grade costs cents per lb
costs cents per lb
costs cents per lb
Invalid choice.
;
iO switchfudGrade
case A messash fudGrade messash;
case B messash fudGrade messash;
case C messash fudGrade messash;
default messash;
;
return iO;
public static void prinoutchar fudGr, String incoming
iffudGr X
System.out.printlnincoming;
else
System.out.printlnincoming;
Average class
public class Average
private double akkum;
private int Count;
public Average Constructor; initializes the class fields
akkum ;
Count ;
public void setSumdouble num Mutator Method Setter
akkum num; This double field is accumulating the values of the numbers entered
public void setCount Mutator Method Setter
Count; This integer counts how many values have been read
public double getSum Accessor Method Getter
return akkum; This double value represents the sum of all the numbers to be averaged
public int getCount Accessor Method Getter
return Count; This integer value represents how many numbers have been entered
public double getAvg Accessor Method Getter
return akkum Count; This double value represents the calculated Average; prevents stale data
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