SlideShare a Scribd company logo
Hello. I need help fixing this Java Code on Eclipse. Please fix parts indicated as "//Fix" or
"//Fill-in". The code given is the first image. Thank you! Sample outputs are given below along
with what the code is required to do. import java til. Random import java til. Scanner public class
GenCheeseShopv2 public static void intro (Stringt] names, double []prices int amounts Fill-in
public static void getAmount (Scanner input, String[] names, int[] amounts) public static void
itemizedList (String[] names, double Prices int[] amounts) Fill-i public static double
calcSubTotal (double prices, int amounts return 0; pub. lic static int discount (double subTotal
return 0; pub. lic static oid print Total (double subTotal int discount) Fill-in public static void mi
args final int MAXCH EESEE DO NOT CHANGE ANYTHING BELOW String[] names new
String CMAXCH EESE double[] prices new double EESE] int[] amounts new int
[MAXCHEESEJ Scanner input new Scanner (Syste intro names, prices, amounts get Amo unt
input, names, amounts double total calcSubTotal (prices, amounts if EESEE 0) System. out print
Display the itemized list? (1 for yes) int itemized input-nex if item 1) itemized List (names,
prices, amounts); System. out. println(); print Total(total, discount total));
Solution
import java.util.Random;
import java.util.Scanner;
public class GenCheeseShopv2 {
public static void intro(String[] names, double[] prices,int[] amounts){
System.out.println("We sell "+names.length+" kinds of cheese");
for(int i=0;i0)
System.out.println(amounts[i]+" lbs of "+names[i]+" @ "+prices[i]+" =
$"+(amounts[i]*prices[i]));
}
}
public static double calcSubTotal( double[] prices,int[] amounts){
double subTotal=0;
for(int i=0;i100)
return 10;
else if(subTotal > 50)
return 25;
else
return 0;
}
public static void printTotal(double subTotal,int discount){
System.out.println("Sub Total : $"+subTotal);
System.out.println("-Discount : $"+discount);
System.out.println("Total : $"+(subTotal-discount));
}
public static void main(String[] args){
final int MAXCHEESES=4;
String[] names = new String[MAXCHEESES];
double[] prices = new double[MAXCHEESES];
int[] amounts = new int[MAXCHEESES];
Scanner input = new Scanner(System.in);
intro(names, prices, amounts);
getAmount(input, names, amounts);
double total = calcSubTotal(prices, amounts);
if(MAXCHEESES>0){
System.out.println("Display the itemized list? (1 for yes)");
int itemized = input.nextInt();
if(itemized==1){
itemizedList(names, prices, amounts);
}
}
System.out.println();
printTotal(total, discount(total));
}
}

More Related Content

PDF
import java.util.;public class Program{public static void.pdf
PDF
Hello, I need some assistance in writing a java program THAT MUST US.pdf
PPTX
Awt components
PDF
Lecture 2 java.pdf
PDF
Java -lec-5
PDF
import java.util.;public class Main{public static void main(S.pdf
PDF
3.Lesson Plan - Input.pdf.pdf
import java.util.;public class Program{public static void.pdf
Hello, I need some assistance in writing a java program THAT MUST US.pdf
Awt components
Lecture 2 java.pdf
Java -lec-5
import java.util.;public class Main{public static void main(S.pdf
3.Lesson Plan - Input.pdf.pdf

Similar to Hello. I need help fixing this Java Code on Eclipse. Please fix part.pdf (20)

PDF
djkkfhulkgyftfdtrdrsdsjjjjjjjjjjjjjjjjjjj
PDF
please send edited code. I have posted this a few times with lots of.pdf
DOCX
Arraysnklkjjkknlnlknnjlnjljljkjnjkjn.docx
PPTX
Chapter 7.1
PDF
Computer java programs
PDF
Prompt a user to enter a series of integers separated by spaces and .pdf
PDF
Transaction is a monad
PDF
An object of class StatCalc can be used to compute several simp.pdf
PPT
New features and enhancement
PDF
Create a menu-driven program that will accept a collection of non-ne.pdf
PPTX
Python programming workshop session 3
PPTX
C++ STL (quickest way to learn, even for absolute beginners).pptx
PPTX
C++ STL (quickest way to learn, even for absolute beginners).pptx
PDF
Hive Functions Cheat Sheet
PDF
Advanced Java - Practical File
PDF
Java Simple Programs
PPT
object oriented programming java lectures
PPT
Java Generics
PPTX
131 Lab slides (all in one)
DOCX
ObjectivesMore practice with recursion.Practice writing some tem.docx
djkkfhulkgyftfdtrdrsdsjjjjjjjjjjjjjjjjjjj
please send edited code. I have posted this a few times with lots of.pdf
Arraysnklkjjkknlnlknnjlnjljljkjnjkjn.docx
Chapter 7.1
Computer java programs
Prompt a user to enter a series of integers separated by spaces and .pdf
Transaction is a monad
An object of class StatCalc can be used to compute several simp.pdf
New features and enhancement
Create a menu-driven program that will accept a collection of non-ne.pdf
Python programming workshop session 3
C++ STL (quickest way to learn, even for absolute beginners).pptx
C++ STL (quickest way to learn, even for absolute beginners).pptx
Hive Functions Cheat Sheet
Advanced Java - Practical File
Java Simple Programs
object oriented programming java lectures
Java Generics
131 Lab slides (all in one)
ObjectivesMore practice with recursion.Practice writing some tem.docx

More from flashfashioncasualwe (20)

PDF
How does the mutation rate of speciation in the Dobzhansky- Muller m.pdf
PDF
Focus on Writing 4. Supporting a Point of View Do you think Social Se.pdf
PDF
Decision-Making Across the Organization The board of trustees of a lo.pdf
PDF
Explain the experience of African-Americans in the South over the co.pdf
PDF
During a diversity management session, a manager suggests that stereo.pdf
PDF
Explain why a mycoplasma PCR kit might give a negative result when u.pdf
PDF
Describe the difference between the MOV instruction and the LEA instr.pdf
PDF
Explain how enzymes work, explaining the four major types of metabol.pdf
PDF
Develop an inventory management system for an electronics store. The .pdf
PDF
Describe one event from your daily life when you have changed your o.pdf
PDF
All answers must be in your own wordsProvide a good, understandabl.pdf
PDF
C programming tweak needed for a specific program.This is the comp.pdf
PDF
Add to BST.java a method height() that computes the height of the tr.pdf
PDF
Write an awareness objective for a newly formed adolescent chemical .pdf
PDF
which of these prokaryotes are most likely to be found in the immedi.pdf
PDF
2. Why is only one end point observed for citric acid even though it .pdf
PDF
10. Benefits and costs of International Trade Search for a newspap.pdf
PDF
Why does the pattern in a shift register shift only one bit position.pdf
PDF
Use the Internet to identify three network firewalls, and create a t.pdf
PDF
To vaccinate or not to vaccinate Is the influenza Virus vaccine Saf.pdf
How does the mutation rate of speciation in the Dobzhansky- Muller m.pdf
Focus on Writing 4. Supporting a Point of View Do you think Social Se.pdf
Decision-Making Across the Organization The board of trustees of a lo.pdf
Explain the experience of African-Americans in the South over the co.pdf
During a diversity management session, a manager suggests that stereo.pdf
Explain why a mycoplasma PCR kit might give a negative result when u.pdf
Describe the difference between the MOV instruction and the LEA instr.pdf
Explain how enzymes work, explaining the four major types of metabol.pdf
Develop an inventory management system for an electronics store. The .pdf
Describe one event from your daily life when you have changed your o.pdf
All answers must be in your own wordsProvide a good, understandabl.pdf
C programming tweak needed for a specific program.This is the comp.pdf
Add to BST.java a method height() that computes the height of the tr.pdf
Write an awareness objective for a newly formed adolescent chemical .pdf
which of these prokaryotes are most likely to be found in the immedi.pdf
2. Why is only one end point observed for citric acid even though it .pdf
10. Benefits and costs of International Trade Search for a newspap.pdf
Why does the pattern in a shift register shift only one bit position.pdf
Use the Internet to identify three network firewalls, and create a t.pdf
To vaccinate or not to vaccinate Is the influenza Virus vaccine Saf.pdf

Recently uploaded (20)

PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PDF
01-Introduction-to-Information-Management.pdf
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PPTX
Pharma ospi slides which help in ospi learning
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PPTX
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
PPTX
Institutional Correction lecture only . . .
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PDF
O7-L3 Supply Chain Operations - ICLT Program
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PDF
RMMM.pdf make it easy to upload and study
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
STATICS OF THE RIGID BODIES Hibbelers.pdf
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
01-Introduction-to-Information-Management.pdf
Supply Chain Operations Speaking Notes -ICLT Program
FourierSeries-QuestionsWithAnswers(Part-A).pdf
Pharma ospi slides which help in ospi learning
102 student loan defaulters named and shamed – Is someone you know on the list?
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
Institutional Correction lecture only . . .
human mycosis Human fungal infections are called human mycosis..pptx
O7-L3 Supply Chain Operations - ICLT Program
Microbial diseases, their pathogenesis and prophylaxis
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
RMMM.pdf make it easy to upload and study
Abdominal Access Techniques with Prof. Dr. R K Mishra
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student

Hello. I need help fixing this Java Code on Eclipse. Please fix part.pdf

  • 1. Hello. I need help fixing this Java Code on Eclipse. Please fix parts indicated as "//Fix" or "//Fill-in". The code given is the first image. Thank you! Sample outputs are given below along with what the code is required to do. import java til. Random import java til. Scanner public class GenCheeseShopv2 public static void intro (Stringt] names, double []prices int amounts Fill-in public static void getAmount (Scanner input, String[] names, int[] amounts) public static void itemizedList (String[] names, double Prices int[] amounts) Fill-i public static double calcSubTotal (double prices, int amounts return 0; pub. lic static int discount (double subTotal return 0; pub. lic static oid print Total (double subTotal int discount) Fill-in public static void mi args final int MAXCH EESEE DO NOT CHANGE ANYTHING BELOW String[] names new String CMAXCH EESE double[] prices new double EESE] int[] amounts new int [MAXCHEESEJ Scanner input new Scanner (Syste intro names, prices, amounts get Amo unt input, names, amounts double total calcSubTotal (prices, amounts if EESEE 0) System. out print Display the itemized list? (1 for yes) int itemized input-nex if item 1) itemized List (names, prices, amounts); System. out. println(); print Total(total, discount total)); Solution import java.util.Random; import java.util.Scanner; public class GenCheeseShopv2 { public static void intro(String[] names, double[] prices,int[] amounts){ System.out.println("We sell "+names.length+" kinds of cheese"); for(int i=0;i0) System.out.println(amounts[i]+" lbs of "+names[i]+" @ "+prices[i]+" = $"+(amounts[i]*prices[i])); } } public static double calcSubTotal( double[] prices,int[] amounts){ double subTotal=0; for(int i=0;i100) return 10; else if(subTotal > 50) return 25; else
  • 2. return 0; } public static void printTotal(double subTotal,int discount){ System.out.println("Sub Total : $"+subTotal); System.out.println("-Discount : $"+discount); System.out.println("Total : $"+(subTotal-discount)); } public static void main(String[] args){ final int MAXCHEESES=4; String[] names = new String[MAXCHEESES]; double[] prices = new double[MAXCHEESES]; int[] amounts = new int[MAXCHEESES]; Scanner input = new Scanner(System.in); intro(names, prices, amounts); getAmount(input, names, amounts); double total = calcSubTotal(prices, amounts); if(MAXCHEESES>0){ System.out.println("Display the itemized list? (1 for yes)"); int itemized = input.nextInt(); if(itemized==1){ itemizedList(names, prices, amounts); } } System.out.println(); printTotal(total, discount(total)); } }