CSC 190 Lecture Notes - Lecture 8: Dime (United States Coin), American Broadcasting Company

17 views3 pages

Document Summary

//purpose: take an amount like . 38 and print the minimum number of coins. //3 + 1 + 1 + 3 = 8 coins (called the change program) import java. util. scanner; public class p0128a { public static void main(string[] args) { Scanner in = new scanner(system. in); double amount; //input int d, q, di, n, p, total; int cents; //purpose: +, -, *, / on two rational numbers. //n1/d1 + n2/d2 = n1*d2/(d1*d2) + n2*d1/(d1*d2) = (n1*d2+n2*d1)/(d1*d2) //1/2 / 2/3 = 1/2 * 3/2 = 3/4 import java. util. scanner; public class p0128b { public static void main(string[] args) { Scanner in = new scanner(system. in); int n1, d1, n2, d2; //input int n3, d3; //output. System. out. print("enter denominator 2: "); d2 = in. nextint(); n3 = n1*d2+n2*d1; d3 = d1*d2; System. out. println(n1+"/"+d1+" + "+n2+"/"+d2+" = "+n3+"/"+d3); n3 = n1*d2-n2*d1; d3 = d1*d2; System. out. println(n1+"/"+d1+" - "+n2+"/"+d2+" = "+n3+"/"+d3); n3 = n1*n2; d3 = d1*d2; System. out. println(n1+"/"+d1+" * "+n2+"/"+d2+" = "+n3+"/"+d3); n3 = n1*d2; d3 = d1*n2;

Get access

Grade+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers
Class+
$30 USD/m
Billed monthly
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
7 Verified Answers

Related Documents

Related Questions