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

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

Chapter 7.1
Chapter 7.1Chapter 7.1
Chapter 7.1
sotlsoc
 
An object of class StatCalc can be used to compute several simp.pdf
 An object of class StatCalc can be used to compute several simp.pdf An object of class StatCalc can be used to compute several simp.pdf
An object of class StatCalc can be used to compute several simp.pdf
aravlitraders2012
 
New features and enhancement
New features and enhancementNew features and enhancement
New features and enhancement
Rakesh Madugula
 
Create a menu-driven program that will accept a collection of non-ne.pdf
Create a menu-driven program that will accept a collection of non-ne.pdfCreate a menu-driven program that will accept a collection of non-ne.pdf
Create a menu-driven program that will accept a collection of non-ne.pdf
rajeshjangid1865
 
ObjectivesMore practice with recursion.Practice writing some tem.docx
ObjectivesMore practice with recursion.Practice writing some tem.docxObjectivesMore practice with recursion.Practice writing some tem.docx
ObjectivesMore practice with recursion.Practice writing some tem.docx
vannagoforth
 
public class TrequeT extends AbstractListT { .pdf
  public class TrequeT extends AbstractListT {  .pdf  public class TrequeT extends AbstractListT {  .pdf
public class TrequeT extends AbstractListT { .pdf
info30292
 

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

please send edited code. I have posted this a few times with lots of.pdf
please send edited code. I have posted this a few times with lots of.pdfplease send edited code. I have posted this a few times with lots of.pdf
please send edited code. I have posted this a few times with lots of.pdf
 
Chapter 7.1
Chapter 7.1Chapter 7.1
Chapter 7.1
 
Computer java programs
Computer java programsComputer java programs
Computer java programs
 
Prompt a user to enter a series of integers separated by spaces and .pdf
Prompt a user to enter a series of integers separated by spaces and .pdfPrompt a user to enter a series of integers separated by spaces and .pdf
Prompt a user to enter a series of integers separated by spaces and .pdf
 
Transaction is a monad
Transaction is a  monadTransaction is a  monad
Transaction is a monad
 
An object of class StatCalc can be used to compute several simp.pdf
 An object of class StatCalc can be used to compute several simp.pdf An object of class StatCalc can be used to compute several simp.pdf
An object of class StatCalc can be used to compute several simp.pdf
 
New features and enhancement
New features and enhancementNew features and enhancement
New features and enhancement
 
Create a menu-driven program that will accept a collection of non-ne.pdf
Create a menu-driven program that will accept a collection of non-ne.pdfCreate a menu-driven program that will accept a collection of non-ne.pdf
Create a menu-driven program that will accept a collection of non-ne.pdf
 
Python programming workshop session 3
Python programming workshop session 3Python programming workshop session 3
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).pptxC++ STL (quickest way to learn, even for absolute beginners).pptx
C++ STL (quickest way to learn, even for absolute beginners).pptx
 
C++ STL (quickest way to learn, even for absolute beginners).pptx
C++ STL (quickest way to learn, even for absolute beginners).pptxC++ 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
Hive Functions Cheat SheetHive Functions Cheat Sheet
Hive Functions Cheat Sheet
 
Advanced Java - Practical File
Advanced Java - Practical FileAdvanced Java - Practical File
Advanced Java - Practical File
 
Java Simple Programs
Java Simple ProgramsJava Simple Programs
Java Simple Programs
 
object oriented programming java lectures
object oriented programming java lecturesobject oriented programming java lectures
object oriented programming java lectures
 
Java Generics
Java GenericsJava Generics
Java Generics
 
131 Lab slides (all in one)
131 Lab slides (all in one)131 Lab slides (all in one)
131 Lab slides (all in one)
 
ObjectivesMore practice with recursion.Practice writing some tem.docx
ObjectivesMore practice with recursion.Practice writing some tem.docxObjectivesMore practice with recursion.Practice writing some tem.docx
ObjectivesMore practice with recursion.Practice writing some tem.docx
 
public class TrequeT extends AbstractListT { .pdf
  public class TrequeT extends AbstractListT {  .pdf  public class TrequeT extends AbstractListT {  .pdf
public class TrequeT extends AbstractListT { .pdf
 
Lezione03
Lezione03Lezione03
Lezione03
 

More from flashfashioncasualwe

Focus on Writing 4. Supporting a Point of View Do you think Social Se.pdf
Focus on Writing 4. Supporting a Point of View Do you think Social Se.pdfFocus on Writing 4. Supporting a Point of View Do you think Social Se.pdf
Focus on Writing 4. Supporting a Point of View Do you think Social Se.pdf
flashfashioncasualwe
 
Decision-Making Across the Organization The board of trustees of a lo.pdf
Decision-Making Across the Organization The board of trustees of a lo.pdfDecision-Making Across the Organization The board of trustees of a lo.pdf
Decision-Making Across the Organization The board of trustees of a lo.pdf
flashfashioncasualwe
 
During a diversity management session, a manager suggests that stereo.pdf
During a diversity management session, a manager suggests that stereo.pdfDuring a diversity management session, a manager suggests that stereo.pdf
During a diversity management session, a manager suggests that stereo.pdf
flashfashioncasualwe
 
Explain why a mycoplasma PCR kit might give a negative result when u.pdf
Explain why a mycoplasma PCR kit might give a negative result when u.pdfExplain why a mycoplasma PCR kit might give a negative result when u.pdf
Explain why a mycoplasma PCR kit might give a negative result when u.pdf
flashfashioncasualwe
 
Explain how enzymes work, explaining the four major types of metabol.pdf
Explain how enzymes work, explaining the four major types of metabol.pdfExplain how enzymes work, explaining the four major types of metabol.pdf
Explain how enzymes work, explaining the four major types of metabol.pdf
flashfashioncasualwe
 
Develop an inventory management system for an electronics store. The .pdf
Develop an inventory management system for an electronics store. The .pdfDevelop an inventory management system for an electronics store. The .pdf
Develop an inventory management system for an electronics store. The .pdf
flashfashioncasualwe
 
Describe one event from your daily life when you have changed your o.pdf
Describe one event from your daily life when you have changed your o.pdfDescribe one event from your daily life when you have changed your o.pdf
Describe one event from your daily life when you have changed your o.pdf
flashfashioncasualwe
 
All answers must be in your own wordsProvide a good, understandabl.pdf
All answers must be in your own wordsProvide a good, understandabl.pdfAll answers must be in your own wordsProvide a good, understandabl.pdf
All answers must be in your own wordsProvide a good, understandabl.pdf
flashfashioncasualwe
 
C programming tweak needed for a specific program.This is the comp.pdf
C programming tweak needed for a specific program.This is the comp.pdfC programming tweak needed for a specific program.This is the comp.pdf
C programming tweak needed for a specific program.This is the comp.pdf
flashfashioncasualwe
 
Add to BST.java a method height() that computes the height of the tr.pdf
Add to BST.java a method height() that computes the height of the tr.pdfAdd to BST.java a method height() that computes the height of the tr.pdf
Add to BST.java a method height() that computes the height of the tr.pdf
flashfashioncasualwe
 
10. Benefits and costs of International Trade Search for a newspap.pdf
10. Benefits and costs of International Trade  Search for a newspap.pdf10. Benefits and costs of International Trade  Search for a newspap.pdf
10. Benefits and costs of International Trade Search for a newspap.pdf
flashfashioncasualwe
 
Use the Internet to identify three network firewalls, and create a t.pdf
Use the Internet to identify three network firewalls, and create a t.pdfUse the Internet to identify three network firewalls, and create a t.pdf
Use the Internet to identify three network firewalls, and create a t.pdf
flashfashioncasualwe
 

More from flashfashioncasualwe (20)

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

Recently uploaded

Industrial Training Report- AKTU Industrial Training Report
Industrial Training Report- AKTU Industrial Training ReportIndustrial Training Report- AKTU Industrial Training Report
Industrial Training Report- AKTU Industrial Training Report
Avinash Rai
 

Recently uploaded (20)

PART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePART A. Introduction to Costumer Service
PART A. Introduction to Costumer Service
 
Industrial Training Report- AKTU Industrial Training Report
Industrial Training Report- AKTU Industrial Training ReportIndustrial Training Report- AKTU Industrial Training Report
Industrial Training Report- AKTU Industrial Training Report
 
Operations Management - Book1.p - Dr. Abdulfatah A. Salem
Operations Management - Book1.p  - Dr. Abdulfatah A. SalemOperations Management - Book1.p  - Dr. Abdulfatah A. Salem
Operations Management - Book1.p - Dr. Abdulfatah A. Salem
 
The Last Leaf, a short story by O. Henry
The Last Leaf, a short story by O. HenryThe Last Leaf, a short story by O. Henry
The Last Leaf, a short story by O. Henry
 
2024_Student Session 2_ Set Plan Preparation.pptx
2024_Student Session 2_ Set Plan Preparation.pptx2024_Student Session 2_ Set Plan Preparation.pptx
2024_Student Session 2_ Set Plan Preparation.pptx
 
Gyanartha SciBizTech Quiz slideshare.pptx
Gyanartha SciBizTech Quiz slideshare.pptxGyanartha SciBizTech Quiz slideshare.pptx
Gyanartha SciBizTech Quiz slideshare.pptx
 
Matatag-Curriculum and the 21st Century Skills Presentation.pptx
Matatag-Curriculum and the 21st Century Skills Presentation.pptxMatatag-Curriculum and the 21st Century Skills Presentation.pptx
Matatag-Curriculum and the 21st Century Skills Presentation.pptx
 
How to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERPHow to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERP
 
[GDSC YCCE] Build with AI Online Presentation
[GDSC YCCE] Build with AI Online Presentation[GDSC YCCE] Build with AI Online Presentation
[GDSC YCCE] Build with AI Online Presentation
 
Telling Your Story_ Simple Steps to Build Your Nonprofit's Brand Webinar.pdf
Telling Your Story_ Simple Steps to Build Your Nonprofit's Brand Webinar.pdfTelling Your Story_ Simple Steps to Build Your Nonprofit's Brand Webinar.pdf
Telling Your Story_ Simple Steps to Build Your Nonprofit's Brand Webinar.pdf
 
Basic_QTL_Marker-assisted_Selection_Sourabh.ppt
Basic_QTL_Marker-assisted_Selection_Sourabh.pptBasic_QTL_Marker-assisted_Selection_Sourabh.ppt
Basic_QTL_Marker-assisted_Selection_Sourabh.ppt
 
Basic Civil Engg Notes_Chapter-6_Environment Pollution & Engineering
Basic Civil Engg Notes_Chapter-6_Environment Pollution & EngineeringBasic Civil Engg Notes_Chapter-6_Environment Pollution & Engineering
Basic Civil Engg Notes_Chapter-6_Environment Pollution & Engineering
 
Basic Civil Engineering Notes of Chapter-6, Topic- Ecosystem, Biodiversity G...
Basic Civil Engineering Notes of Chapter-6,  Topic- Ecosystem, Biodiversity G...Basic Civil Engineering Notes of Chapter-6,  Topic- Ecosystem, Biodiversity G...
Basic Civil Engineering Notes of Chapter-6, Topic- Ecosystem, Biodiversity G...
 
Application of Matrices in real life. Presentation on application of matrices
Application of Matrices in real life. Presentation on application of matricesApplication of Matrices in real life. Presentation on application of matrices
Application of Matrices in real life. Presentation on application of matrices
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative Thoughts
 
Open Educational Resources Primer PowerPoint
Open Educational Resources Primer PowerPointOpen Educational Resources Primer PowerPoint
Open Educational Resources Primer PowerPoint
 
NCERT Solutions Power Sharing Class 10 Notes pdf
NCERT Solutions Power Sharing Class 10 Notes pdfNCERT Solutions Power Sharing Class 10 Notes pdf
NCERT Solutions Power Sharing Class 10 Notes pdf
 
Danh sách HSG Bộ môn cấp trường - Cấp THPT.pdf
Danh sách HSG Bộ môn cấp trường - Cấp THPT.pdfDanh sách HSG Bộ môn cấp trường - Cấp THPT.pdf
Danh sách HSG Bộ môn cấp trường - Cấp THPT.pdf
 
The Benefits and Challenges of Open Educational Resources
The Benefits and Challenges of Open Educational ResourcesThe Benefits and Challenges of Open Educational Resources
The Benefits and Challenges of Open Educational Resources
 
How to Manage Notification Preferences in the Odoo 17
How to Manage Notification Preferences in the Odoo 17How to Manage Notification Preferences in the Odoo 17
How to Manage Notification Preferences in the Odoo 17
 

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)); } }