SlideShare a Scribd company logo
import java.util.*;
public class Main
{
public static void main(String args[])
{
double paid;
double cost;
double change;
Scanner s=new Scanner(System.in);
System.out.println("enter amount paid :");
paid=s.nextDouble();
System.out.println("enter item cost :");
cost=s.nextDouble();
change=paid-cost;
System.out.println("Change owed : "+change);
double currency[4]={0.25,0.10,0.05,0.01};
String currency_name[]={"Quarters","Dimes","Nickels","Pennies"};
double currency_count[]=new double[4];
for(int i=0;i<4;i++)
{
currency_count[i]=0;
for(int j=1;;j++)
{
if(change-(currency[i]*j)>=0.0)
{
currency_count[i]=j;
}
else
{
change=change-(currency[i]*currency_count[i]);
break;
}
}
}
for(int k=0;k<4;k++)
{
System.out.println(currency_name[k]+" : "+currency_count[k]);
}
}
}
Solution
import java.util.*;
public class Main
{
public static void main(String args[])
{
double paid;
double cost;
double change;
Scanner s=new Scanner(System.in);
System.out.println("enter amount paid :");
paid=s.nextDouble();
System.out.println("enter item cost :");
cost=s.nextDouble();
change=paid-cost;
System.out.println("Change owed : "+change);
double currency[4]={0.25,0.10,0.05,0.01};
String currency_name[]={"Quarters","Dimes","Nickels","Pennies"};
double currency_count[]=new double[4];
for(int i=0;i<4;i++)
{
currency_count[i]=0;
for(int j=1;;j++)
{
if(change-(currency[i]*j)>=0.0)
{
currency_count[i]=j;
}
else
{
change=change-(currency[i]*currency_count[i]);
break;
}
}
}
for(int k=0;k<4;k++)
{
System.out.println(currency_name[k]+" : "+currency_count[k]);
}
}
}

More Related Content

PDF
import java.util.Scanner; import java.math.BigInteger; public cl.pdf
DOC
capstoneCMPSC101
PDF
import java.util.Scanner;import java.text.DecimalFormat;import j.pdf
PDF
Bank Program in JavaBelow is my code(havent finished, but it be .pdf
TXT
PDF
SavingsAccount.javapublic class SavingsAccount{             .pdf
PDF
Hello. I need help fixing this Java Code on Eclipse. Please fix part.pdf
PDF
Hey, looking to do the following with this programFill in the multip.pdf
import java.util.Scanner; import java.math.BigInteger; public cl.pdf
capstoneCMPSC101
import java.util.Scanner;import java.text.DecimalFormat;import j.pdf
Bank Program in JavaBelow is my code(havent finished, but it be .pdf
SavingsAccount.javapublic class SavingsAccount{             .pdf
Hello. I need help fixing this Java Code on Eclipse. Please fix part.pdf
Hey, looking to do the following with this programFill in the multip.pdf

More from deepua8 (20)

PDF
Balancing ANY chemical equation is done exactly t.pdf
PDF
36.Kovacs reagent is used in Indole test. Kovacs reagent is 4 (p)-.pdf
PDF
10.Real number1.Baseb. Consists of a set and rule for combining2.Bin.pdf
PDF
1. Yeasts grow by budding. The cell buds and separates into 2 cells..pdf
PDF
1. 252.125Solution1. 252.125.pdf
PDF
(B) 0.815Solution(B) 0.815.pdf
PDF
Suppose AFnSolution Suppose AFn.pdf
PDF
C code on linked list #include stdio.h #include stdlib.h.pdf
PDF
Definition of Log-Normal DistributionA statistical distr.pdf
PDF
Step1 NaOH (aq) ----- Na(+)(aq) + Cl(-)(aq) Ste.pdf
PDF
The compounds with low oxidation states (O.S.) be.pdf
PDF
A) ionic compounds generally formed between the c.pdf
PDF
A ethers ethers contain R-O-R linkage not carbony.pdf
PDF
The fact that a molecule vibrates does not in its.pdf
PDF
The compounds of interest are Na2S and H2SO4. Th.pdf
PDF
sucrose has a formula of C12H22O11while ammonia h.pdf
PDF
reduction strength Fe Pb As .pdf
PDF
sp3d since it has 1s 3p and 1d orbitals available.pdf
PDF
No standard potential data given. .pdf
PDF
x2 + 4xSolutionx2 + 4x.pdf
Balancing ANY chemical equation is done exactly t.pdf
36.Kovacs reagent is used in Indole test. Kovacs reagent is 4 (p)-.pdf
10.Real number1.Baseb. Consists of a set and rule for combining2.Bin.pdf
1. Yeasts grow by budding. The cell buds and separates into 2 cells..pdf
1. 252.125Solution1. 252.125.pdf
(B) 0.815Solution(B) 0.815.pdf
Suppose AFnSolution Suppose AFn.pdf
C code on linked list #include stdio.h #include stdlib.h.pdf
Definition of Log-Normal DistributionA statistical distr.pdf
Step1 NaOH (aq) ----- Na(+)(aq) + Cl(-)(aq) Ste.pdf
The compounds with low oxidation states (O.S.) be.pdf
A) ionic compounds generally formed between the c.pdf
A ethers ethers contain R-O-R linkage not carbony.pdf
The fact that a molecule vibrates does not in its.pdf
The compounds of interest are Na2S and H2SO4. Th.pdf
sucrose has a formula of C12H22O11while ammonia h.pdf
reduction strength Fe Pb As .pdf
sp3d since it has 1s 3p and 1d orbitals available.pdf
No standard potential data given. .pdf
x2 + 4xSolutionx2 + 4x.pdf
Ad

Recently uploaded (20)

PDF
RMMM.pdf make it easy to upload and study
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PPTX
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
PPTX
Cell Structure & Organelles in detailed.
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PPTX
202450812 BayCHI UCSC-SV 20250812 v17.pptx
PDF
A systematic review of self-coping strategies used by university students to ...
PDF
Chinmaya Tiranga quiz Grand Finale.pdf
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PPTX
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
PPTX
Cell Types and Its function , kingdom of life
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PDF
Computing-Curriculum for Schools in Ghana
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PPTX
Institutional Correction lecture only . . .
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
PPTX
GDM (1) (1).pptx small presentation for students
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PDF
GENETICS IN BIOLOGY IN SECONDARY LEVEL FORM 3
RMMM.pdf make it easy to upload and study
O5-L3 Freight Transport Ops (International) V1.pdf
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
Cell Structure & Organelles in detailed.
Microbial diseases, their pathogenesis and prophylaxis
202450812 BayCHI UCSC-SV 20250812 v17.pptx
A systematic review of self-coping strategies used by university students to ...
Chinmaya Tiranga quiz Grand Finale.pdf
Abdominal Access Techniques with Prof. Dr. R K Mishra
STATICS OF THE RIGID BODIES Hibbelers.pdf
IMMUNITY IMMUNITY refers to protection against infection, and the immune syst...
Cell Types and Its function , kingdom of life
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
Computing-Curriculum for Schools in Ghana
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
Institutional Correction lecture only . . .
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
GDM (1) (1).pptx small presentation for students
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
GENETICS IN BIOLOGY IN SECONDARY LEVEL FORM 3
Ad

import java.util.;public class Main{public static void main(S.pdf

  • 1. import java.util.*; public class Main { public static void main(String args[]) { double paid; double cost; double change; Scanner s=new Scanner(System.in); System.out.println("enter amount paid :"); paid=s.nextDouble(); System.out.println("enter item cost :"); cost=s.nextDouble(); change=paid-cost; System.out.println("Change owed : "+change); double currency[4]={0.25,0.10,0.05,0.01}; String currency_name[]={"Quarters","Dimes","Nickels","Pennies"}; double currency_count[]=new double[4]; for(int i=0;i<4;i++) { currency_count[i]=0; for(int j=1;;j++) { if(change-(currency[i]*j)>=0.0) { currency_count[i]=j; } else { change=change-(currency[i]*currency_count[i]); break; } } } for(int k=0;k<4;k++)
  • 2. { System.out.println(currency_name[k]+" : "+currency_count[k]); } } } Solution import java.util.*; public class Main { public static void main(String args[]) { double paid; double cost; double change; Scanner s=new Scanner(System.in); System.out.println("enter amount paid :"); paid=s.nextDouble(); System.out.println("enter item cost :"); cost=s.nextDouble(); change=paid-cost; System.out.println("Change owed : "+change); double currency[4]={0.25,0.10,0.05,0.01}; String currency_name[]={"Quarters","Dimes","Nickels","Pennies"}; double currency_count[]=new double[4]; for(int i=0;i<4;i++) { currency_count[i]=0; for(int j=1;;j++) { if(change-(currency[i]*j)>=0.0) { currency_count[i]=j; } else