Homework 10-17 Project 2.05 (1st ed.)
package homework;
import java.io.*;
import javax.swing.JOptionPane;
public class Homework_10_17 {
public Homework_10_17() {
}
public static void main(String[] args){
String PriceString=JOptionPane.showInputDialog("Enter price of item\n"+
"(from 25 cents to a dollar, in 5-cent increments):");
int price=Integer.parseInt(PriceString);
System.out.println("You bought an item for " + price +
" cents and gave me a dollar,\n"+"so your change is");
price = 100 - price;
int quarter=0,dime=0,nickel=0;
while(price >= 25) {
quarter = price / 25;
price = price - 25 * quarter;
}
while(price>=10 &&amp;amp;amp;amp; price <25){ dime =" price" price =" price">=5 && price <10){ nickel =" price" price =" price" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://photos1.blogger.com/blogger/3473/1585/1600/10_17_2_1.jpg">
import java.io.*;
import javax.swing.JOptionPane;
public class Homework_10_17 {
public Homework_10_17() {
}
public static void main(String[] args){
String PriceString=JOptionPane.showInputDialog("Enter price of item\n"+
"(from 25 cents to a dollar, in 5-cent increments):");
int price=Integer.parseInt(PriceString);
System.out.println("You bought an item for " + price +
" cents and gave me a dollar,\n"+"so your change is");
price = 100 - price;
int quarter=0,dime=0,nickel=0;
while(price >= 25) {
quarter = price / 25;
price = price - 25 * quarter;
}
while(price>=10 &&amp;amp;amp;amp; price <25){ dime =" price" price =" price">=5 && price <10){ nickel =" price" price =" price" onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://photos1.blogger.com/blogger/3473/1585/1600/10_17_2_1.jpg">
0 Comments:
張貼留言
<< Home