SlideShare a Scribd company logo
1 of 3
Download to read offline
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

Similar to import java.util.;public class Main{public static void main(S.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
An object of class StatCalc can be used to compute several simp.pdf
aravlitraders2012
 
FileName EX06_1java Programmer import ja.pdf
FileName EX06_1java Programmer  import ja.pdfFileName EX06_1java Programmer  import ja.pdf
FileName EX06_1java Programmer import ja.pdf
actocomputer
 
You are not setting any values for those variables(name, ID, interes.pdf
You are not setting any values for those variables(name, ID, interes.pdfYou are not setting any values for those variables(name, ID, interes.pdf
You are not setting any values for those variables(name, ID, interes.pdf
deepakangel
 
import java.util.;public class Program{public static void.pdf
import java.util.;public class Program{public static void.pdfimport java.util.;public class Program{public static void.pdf
import java.util.;public class Program{public static void.pdf
optokunal1
 
import java.util.Scanner;public class ArrayOperation {    inp.pdf
import java.util.Scanner;public class ArrayOperation {     inp.pdfimport java.util.Scanner;public class ArrayOperation {     inp.pdf
import java.util.Scanner;public class ArrayOperation {    inp.pdf
angelsfashion1
 
LECTURE 2 MORE TYPES, METHODS, CONDITIONALS.pdf
LECTURE 2 MORE TYPES, METHODS, CONDITIONALS.pdfLECTURE 2 MORE TYPES, METHODS, CONDITIONALS.pdf
LECTURE 2 MORE TYPES, METHODS, CONDITIONALS.pdf
ShashikantSathe3
 
InsertionSorting.javaimport java.util.Arrays; import java.util.S.pdf
InsertionSorting.javaimport java.util.Arrays; import java.util.S.pdfInsertionSorting.javaimport java.util.Arrays; import java.util.S.pdf
InsertionSorting.javaimport java.util.Arrays; import java.util.S.pdf
info54093
 
define a class name Employee whose objects are records for employee..pdf
define a class name Employee whose objects are records for employee..pdfdefine a class name Employee whose objects are records for employee..pdf
define a class name Employee whose objects are records for employee..pdf
fashioncollection2
 
JAVA.Q4 Create a Time class. This class will represent a point in.pdf
JAVA.Q4 Create a Time class. This class will represent a point in.pdfJAVA.Q4 Create a Time class. This class will represent a point in.pdf
JAVA.Q4 Create a Time class. This class will represent a point in.pdf
karymadelaneyrenne19
 

Similar to import java.util.;public class Main{public static void main(S.pdf (15)

java experiments and programs
java experiments and programsjava experiments and programs
java experiments and programs
 
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
 
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
 
.net progrmming part2
.net progrmming part2.net progrmming part2
.net progrmming part2
 
FileName EX06_1java Programmer import ja.pdf
FileName EX06_1java Programmer  import ja.pdfFileName EX06_1java Programmer  import ja.pdf
FileName EX06_1java Programmer import ja.pdf
 
MagicSquareTest.java import java.util.Scanner;public class Mag.pdf
MagicSquareTest.java import java.util.Scanner;public class Mag.pdfMagicSquareTest.java import java.util.Scanner;public class Mag.pdf
MagicSquareTest.java import java.util.Scanner;public class Mag.pdf
 
You are not setting any values for those variables(name, ID, interes.pdf
You are not setting any values for those variables(name, ID, interes.pdfYou are not setting any values for those variables(name, ID, interes.pdf
You are not setting any values for those variables(name, ID, interes.pdf
 
Please follow the code and comments for description and outputs C.pdf
Please follow the code and comments for description and outputs C.pdfPlease follow the code and comments for description and outputs C.pdf
Please follow the code and comments for description and outputs C.pdf
 
import java.util.;public class Program{public static void.pdf
import java.util.;public class Program{public static void.pdfimport java.util.;public class Program{public static void.pdf
import java.util.;public class Program{public static void.pdf
 
import java.util.Scanner;public class ArrayOperation {    inp.pdf
import java.util.Scanner;public class ArrayOperation {     inp.pdfimport java.util.Scanner;public class ArrayOperation {     inp.pdf
import java.util.Scanner;public class ArrayOperation {    inp.pdf
 
LECTURE 2 MORE TYPES, METHODS, CONDITIONALS.pdf
LECTURE 2 MORE TYPES, METHODS, CONDITIONALS.pdfLECTURE 2 MORE TYPES, METHODS, CONDITIONALS.pdf
LECTURE 2 MORE TYPES, METHODS, CONDITIONALS.pdf
 
InsertionSorting.javaimport java.util.Arrays; import java.util.S.pdf
InsertionSorting.javaimport java.util.Arrays; import java.util.S.pdfInsertionSorting.javaimport java.util.Arrays; import java.util.S.pdf
InsertionSorting.javaimport java.util.Arrays; import java.util.S.pdf
 
define a class name Employee whose objects are records for employee..pdf
define a class name Employee whose objects are records for employee..pdfdefine a class name Employee whose objects are records for employee..pdf
define a class name Employee whose objects are records for employee..pdf
 
Chapter i(introduction to java)
Chapter i(introduction to java)Chapter i(introduction to java)
Chapter i(introduction to java)
 
JAVA.Q4 Create a Time class. This class will represent a point in.pdf
JAVA.Q4 Create a Time class. This class will represent a point in.pdfJAVA.Q4 Create a Time class. This class will represent a point in.pdf
JAVA.Q4 Create a Time class. This class will represent a point in.pdf
 

More from deepua8

Balancing ANY chemical equation is done exactly t.pdf
                     Balancing ANY chemical equation is done exactly t.pdf                     Balancing ANY chemical equation is done exactly t.pdf
Balancing ANY chemical equation is done exactly t.pdf
deepua8
 
A) ionic compounds generally formed between the c.pdf
                     A) ionic compounds generally formed between the c.pdf                     A) ionic compounds generally formed between the c.pdf
A) ionic compounds generally formed between the c.pdf
deepua8
 
The fact that a molecule vibrates does not in its.pdf
                     The fact that a molecule vibrates does not in its.pdf                     The fact that a molecule vibrates does not in its.pdf
The fact that a molecule vibrates does not in its.pdf
deepua8
 

More from deepua8 (20)

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

Recently uploaded

Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
EADTU
 
SPLICE Working Group: Reusable Code Examples
SPLICE Working Group:Reusable Code ExamplesSPLICE Working Group:Reusable Code Examples
SPLICE Working Group: Reusable Code Examples
Peter Brusilovsky
 
MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...
MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...
MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...
MysoreMuleSoftMeetup
 
Personalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes GuàrdiaPersonalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes Guàrdia
EADTU
 
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
AnaAcapella
 

Recently uploaded (20)

Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
Transparency, Recognition and the role of eSealing - Ildiko Mazar and Koen No...
 
An overview of the various scriptures in Hinduism
An overview of the various scriptures in HinduismAn overview of the various scriptures in Hinduism
An overview of the various scriptures in Hinduism
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
 
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUMDEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
DEMONSTRATION LESSON IN ENGLISH 4 MATATAG CURRICULUM
 
SPLICE Working Group: Reusable Code Examples
SPLICE Working Group:Reusable Code ExamplesSPLICE Working Group:Reusable Code Examples
SPLICE Working Group: Reusable Code Examples
 
Major project report on Tata Motors and its marketing strategies
Major project report on Tata Motors and its marketing strategiesMajor project report on Tata Motors and its marketing strategies
Major project report on Tata Motors and its marketing strategies
 
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjjStl Algorithms in C++ jjjjjjjjjjjjjjjjjj
Stl Algorithms in C++ jjjjjjjjjjjjjjjjjj
 
MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...
MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...
MuleSoft Integration with AWS Textract | Calling AWS Textract API |AWS - Clou...
 
OSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsOSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & Systems
 
Personalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes GuàrdiaPersonalisation of Education by AI and Big Data - Lourdes Guàrdia
Personalisation of Education by AI and Big Data - Lourdes Guàrdia
 
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPSSpellings Wk 4 and Wk 5 for Grade 4 at CAPS
Spellings Wk 4 and Wk 5 for Grade 4 at CAPS
 
OS-operating systems- ch05 (CPU Scheduling) ...
OS-operating systems- ch05 (CPU Scheduling) ...OS-operating systems- ch05 (CPU Scheduling) ...
OS-operating systems- ch05 (CPU Scheduling) ...
 
When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...When Quality Assurance Meets Innovation in Higher Education - Report launch w...
When Quality Assurance Meets Innovation in Higher Education - Report launch w...
 
Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...
 
PSYPACT- Practicing Over State Lines May 2024.pptx
PSYPACT- Practicing Over State Lines May 2024.pptxPSYPACT- Practicing Over State Lines May 2024.pptx
PSYPACT- Practicing Over State Lines May 2024.pptx
 
Rich Dad Poor Dad ( PDFDrive.com )--.pdf
Rich Dad Poor Dad ( PDFDrive.com )--.pdfRich Dad Poor Dad ( PDFDrive.com )--.pdf
Rich Dad Poor Dad ( PDFDrive.com )--.pdf
 
How to Manage Website in Odoo 17 Studio App.pptx
How to Manage Website in Odoo 17 Studio App.pptxHow to Manage Website in Odoo 17 Studio App.pptx
How to Manage Website in Odoo 17 Studio App.pptx
 
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
 
Supporting Newcomer Multilingual Learners
Supporting Newcomer  Multilingual LearnersSupporting Newcomer  Multilingual Learners
Supporting Newcomer Multilingual Learners
 
The Story of Village Palampur Class 9 Free Study Material PDF
The Story of Village Palampur Class 9 Free Study Material PDFThe Story of Village Palampur Class 9 Free Study Material PDF
The Story of Village Palampur Class 9 Free Study Material PDF
 

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