SlideShare a Scribd company logo
import java.util.Scanner;
import java.math.BigInteger;
public class Money{
private int dollars;
private int cents;
public Money(){
dollars=0;
cents=0;
}
public Money(int d,int c){
dollars=d+c/100;
cents=c%100;
}
public Money(int c){
dollars=c/100;
cents=c%100;
}
public void add(int c){
cents+=c;
dollars+=cents/100;
cents=cents%100;
}
public void add(int d,int c){
cents+=c;
dollars=dollars+d+cents/100;
cents=cents%100;
}
public void remove(int c){
cents=dollars*100+cents;
if(c>cents){
cents=0;
}
else{
cents-=c;
}
dollars=cents/100;
cents=cents%100;
}
public String getMoney(){
return dollars+" dollars and "+cents+" cents";
}
public static void main(String []args){
Money h=new Money(1,75);
h.add(190);
System.out.println(h.getMoney());
}
}
Solution
import java.util.Scanner;
import java.math.BigInteger;
public class Money{
private int dollars;
private int cents;
public Money(){
dollars=0;
cents=0;
}
public Money(int d,int c){
dollars=d+c/100;
cents=c%100;
}
public Money(int c){
dollars=c/100;
cents=c%100;
}
public void add(int c){
cents+=c;
dollars+=cents/100;
cents=cents%100;
}
public void add(int d,int c){
cents+=c;
dollars=dollars+d+cents/100;
cents=cents%100;
}
public void remove(int c){
cents=dollars*100+cents;
if(c>cents){
cents=0;
}
else{
cents-=c;
}
dollars=cents/100;
cents=cents%100;
}
public String getMoney(){
return dollars+" dollars and "+cents+" cents";
}
public static void main(String []args){
Money h=new Money(1,75);
h.add(190);
System.out.println(h.getMoney());
}
}

More Related Content

PDF
import java.util.Scanner;import java.text.DecimalFormat;import j.pdf
PDF
SavingsAccount.javapublic class SavingsAccount{             .pdf
PDF
import java.util.;public class Main{public static void main(S.pdf
PDF
Hi,I have updated the code as per your requirement. Highlighted th.pdf
PDF
This project calls for the modification of the DollarFormat clas.pdf
PDF
Hey, looking to do the following with this programFill in the multip.pdf
PDF
Bank Program in JavaBelow is my code(havent finished, but it be .pdf
PDF
I need help creating a basic and simple Java program. Here is the ex.pdf
import java.util.Scanner;import java.text.DecimalFormat;import j.pdf
SavingsAccount.javapublic class SavingsAccount{             .pdf
import java.util.;public class Main{public static void main(S.pdf
Hi,I have updated the code as per your requirement. Highlighted th.pdf
This project calls for the modification of the DollarFormat clas.pdf
Hey, looking to do the following with this programFill in the multip.pdf
Bank Program in JavaBelow is my code(havent finished, but it be .pdf
I need help creating a basic and simple Java program. Here is the ex.pdf

Similar to import java.util.Scanner; import java.math.BigInteger; public cl.pdf (20)

PDF
Java programI made this Account.java below. Using the attached cod.pdf
PDF
BankAccount.java A bank account has a balance that can be cha.pdf
PPT
Chapter 4 Powerpoint
KEY
Beautiful Development ブレイクスルー体験記
TXT
DOCX
java experiments and programs
PDF
You are not setting any values for those variables(name, ID, interes.pdf
DOCX
Example of JAVA Program
PDF
Inheritance
DOCX
Write a banking program that simulates the operation of your local ba.docx
PDF
Create a new Java project and add the Account class into the source co.pdf
PDF
Banks offer various types of accounts, such as savings, checking, cer.pdf
PDF
The java class Account that simultes the Account class.pdf
PDF
Interest.javaimport java.util.Scanner; public class Interest.pdf
PDF
public class Interest{double interest(double rate, double amount){.pdf
PDF
help me Java projectI put problem and my own code in the linkmy .pdf
PDF
oop presentation note
PDF
Howto get input with java
PDF
public class NegativeAmountException extends Exception {    .pdf
DOC
5 Rmi Print
Java programI made this Account.java below. Using the attached cod.pdf
BankAccount.java A bank account has a balance that can be cha.pdf
Chapter 4 Powerpoint
Beautiful Development ブレイクスルー体験記
java experiments and programs
You are not setting any values for those variables(name, ID, interes.pdf
Example of JAVA Program
Inheritance
Write a banking program that simulates the operation of your local ba.docx
Create a new Java project and add the Account class into the source co.pdf
Banks offer various types of accounts, such as savings, checking, cer.pdf
The java class Account that simultes the Account class.pdf
Interest.javaimport java.util.Scanner; public class Interest.pdf
public class Interest{double interest(double rate, double amount){.pdf
help me Java projectI put problem and my own code in the linkmy .pdf
oop presentation note
Howto get input with java
public class NegativeAmountException extends Exception {    .pdf
5 Rmi Print

More from annucommunication1 (20)

PDF
4r = 2 L2r = L2thats none of the above, since you didnt wrote t.pdf
PDF
41.Ans. Ans,Sarcoplasmic reticulumSarcoplasmic reticulum is a type.pdf
PDF
1.c. developers2.e. A and B3.c. Land and Built space4. Money a.pdf
PDF
package patienttest;import java.util.Comparator; import java..pdf
PDF
ZnO + H2O = Zn(OH)2 .pdf
PDF
will result in the formation of a soluble complex.pdf
PDF
What types of elements are involved in metallic b.pdf
PDF
The correct statements are When two atoms of app.pdf
PDF
Sure can There you go. .pdf
PDF
One P2O5 contains five oxygen 3.45 x 5 = 17.3 mol.pdf
PDF
Na2O is basic NO2 is acidic SO2 is acidic CO2 is .pdf
PDF
moles of CO2 = moles of NaHCO3 = 284 =0.0238 .pdf
PDF
Eukaryotic Chromosome Structure The length of DN.pdf
PDF
Fe + S ---- FeS moles of Fe = 9.4256 = 0.1682 m.pdf
PDF
D. is correct. Solution .pdf
PDF
The various ways to finance a project are 1)Debt financing-One ca.pdf
PDF
boiling point 1-propanol propanone note there.pdf
PDF
The organs of urinary system includesPaired kidneys, paired ureter.pdf
PDF
The incorrect statement ise. Glucose is a stereoisomer of ribose..pdf
PDF
The answer is a. The intermolecular forces are much greater in wate.pdf
4r = 2 L2r = L2thats none of the above, since you didnt wrote t.pdf
41.Ans. Ans,Sarcoplasmic reticulumSarcoplasmic reticulum is a type.pdf
1.c. developers2.e. A and B3.c. Land and Built space4. Money a.pdf
package patienttest;import java.util.Comparator; import java..pdf
ZnO + H2O = Zn(OH)2 .pdf
will result in the formation of a soluble complex.pdf
What types of elements are involved in metallic b.pdf
The correct statements are When two atoms of app.pdf
Sure can There you go. .pdf
One P2O5 contains five oxygen 3.45 x 5 = 17.3 mol.pdf
Na2O is basic NO2 is acidic SO2 is acidic CO2 is .pdf
moles of CO2 = moles of NaHCO3 = 284 =0.0238 .pdf
Eukaryotic Chromosome Structure The length of DN.pdf
Fe + S ---- FeS moles of Fe = 9.4256 = 0.1682 m.pdf
D. is correct. Solution .pdf
The various ways to finance a project are 1)Debt financing-One ca.pdf
boiling point 1-propanol propanone note there.pdf
The organs of urinary system includesPaired kidneys, paired ureter.pdf
The incorrect statement ise. Glucose is a stereoisomer of ribose..pdf
The answer is a. The intermolecular forces are much greater in wate.pdf

Recently uploaded (20)

PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PDF
Microbial disease of the cardiovascular and lymphatic systems
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PPTX
GDM (1) (1).pptx small presentation for students
PPTX
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
PDF
Chinmaya Tiranga quiz Grand Finale.pdf
PPTX
Pharma ospi slides which help in ospi learning
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PDF
Classroom Observation Tools for Teachers
PDF
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PDF
O7-L3 Supply Chain Operations - ICLT Program
PDF
VCE English Exam - Section C Student Revision Booklet
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PDF
A systematic review of self-coping strategies used by university students to ...
PDF
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
Module 4: Burden of Disease Tutorial Slides S2 2025
Microbial disease of the cardiovascular and lymphatic systems
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
Abdominal Access Techniques with Prof. Dr. R K Mishra
GDM (1) (1).pptx small presentation for students
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
Chinmaya Tiranga quiz Grand Finale.pdf
Pharma ospi slides which help in ospi learning
Pharmacology of Heart Failure /Pharmacotherapy of CHF
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
Classroom Observation Tools for Teachers
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
2.FourierTransform-ShortQuestionswithAnswers.pdf
O7-L3 Supply Chain Operations - ICLT Program
VCE English Exam - Section C Student Revision Booklet
STATICS OF THE RIGID BODIES Hibbelers.pdf
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
A systematic review of self-coping strategies used by university students to ...
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf

import java.util.Scanner; import java.math.BigInteger; public cl.pdf

  • 1. import java.util.Scanner; import java.math.BigInteger; public class Money{ private int dollars; private int cents; public Money(){ dollars=0; cents=0; } public Money(int d,int c){ dollars=d+c/100; cents=c%100; } public Money(int c){ dollars=c/100; cents=c%100; } public void add(int c){ cents+=c; dollars+=cents/100; cents=cents%100; } public void add(int d,int c){ cents+=c; dollars=dollars+d+cents/100; cents=cents%100; } public void remove(int c){ cents=dollars*100+cents;
  • 2. if(c>cents){ cents=0; } else{ cents-=c; } dollars=cents/100; cents=cents%100; } public String getMoney(){ return dollars+" dollars and "+cents+" cents"; } public static void main(String []args){ Money h=new Money(1,75); h.add(190); System.out.println(h.getMoney()); } } Solution import java.util.Scanner; import java.math.BigInteger; public class Money{ private int dollars; private int cents; public Money(){ dollars=0; cents=0; } public Money(int d,int c){ dollars=d+c/100; cents=c%100;
  • 3. } public Money(int c){ dollars=c/100; cents=c%100; } public void add(int c){ cents+=c; dollars+=cents/100; cents=cents%100; } public void add(int d,int c){ cents+=c; dollars=dollars+d+cents/100; cents=cents%100; } public void remove(int c){ cents=dollars*100+cents; if(c>cents){ cents=0; } else{ cents-=c; } dollars=cents/100; cents=cents%100; } public String getMoney(){ return dollars+" dollars and "+cents+" cents"; } public static void main(String []args){ Money h=new Money(1,75);