58,454
社区成员
发帖
与我相关
我的任务
分享
import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.util.Scanner;
public class test4 {
public static void main(String[] args) {
final double OUNCES_PER_POUND=16.0;
double pricePerPound;
double weightOunces;
double weight;
double totalPrice;
Scanner scan=new Scanner(System.in);
NumberFormat money=null;
DecimalFormat fmt= null;
System.out.println("Welcome to the cs Deli!!\n");
System.out.println("Enter the price per pound of your item: ");
pricePerPound= 4.25;
System.out.println("Enter the weight (ounces): ");
weightOunces= 0.16 * 16;
weight=weightOunces/OUNCES_PER_POUND;
totalPrice=pricePerPound*weight;
System.out.println("**** CS Deli ****\n\n");
System.out.println("Unit Price:"+ "¥" + pricePerPound+" per pound\n");
System.out.println("Weight:"+ weight +" pounds\n\n");
System.out.println("TOTAL: "+ "¥" + totalPrice);
}
}
这种问题很基础的,多看看书,扎实基础