今天我重拾书本,希望找回丢失的旧时光
2014-04-06 14:37
344 查看
Java语言程序设计, 第一页开始, 学习中
我甚至连最简单的都不明白
package home.gr;
import java.util.Scanner;
public class CakeSale {
public static void main(String args[])
{
float price;
float weight;
float sum;
price=50.0f;
System.out.println("原价:"+price+"元/磅");
System.out.print("\n 请输入冰激凌蛋糕的重量(磅):");
Scanner scanner=new Scanner(System.in);
weight=scanner.nextFloat();
if(weight>=2&&weight<3)
{
price=(float)(price*0.9);
System.out.print("\n输入重量为"+weight+"磅,能享受9折优惠,打折后价格:"+price+"元/磅");
}
else if(weight>=3)
{
price=(float)(price*0.8);
System.out.print("\n输入重量为"+weight+"磅,能享受8折优惠,打折后价格:"+price+"元/磅");
}
else
{
System.out.print("\n输入重量为"+weight+"磅,不能享受优惠。");
}
sum=price*weight;
System.out.println("\n应收金额为:"+sum+"元。");
}
}
Scanner nextFloat
我甚至连最简单的都不明白
package home.gr;
import java.util.Scanner;
public class CakeSale {
public static void main(String args[])
{
float price;
float weight;
float sum;
price=50.0f;
System.out.println("原价:"+price+"元/磅");
System.out.print("\n 请输入冰激凌蛋糕的重量(磅):");
Scanner scanner=new Scanner(System.in);
weight=scanner.nextFloat();
if(weight>=2&&weight<3)
{
price=(float)(price*0.9);
System.out.print("\n输入重量为"+weight+"磅,能享受9折优惠,打折后价格:"+price+"元/磅");
}
else if(weight>=3)
{
price=(float)(price*0.8);
System.out.print("\n输入重量为"+weight+"磅,能享受8折优惠,打折后价格:"+price+"元/磅");
}
else
{
System.out.print("\n输入重量为"+weight+"磅,不能享受优惠。");
}
sum=price*weight;
System.out.println("\n应收金额为:"+sum+"元。");
}
}
Scanner nextFloat
相关文章推荐
- 今天找回账号,但博客内容都丢失了
- 找回VS工具栏中丢失的行缩进按钮
- 故障造成的数据丢失一般能够找回
- 如何通过xenserver导出的SSR找回丢失的vm Metadata
- 技术QA:如何找回丢失的证书模板或将独立CA转换成企业CA?
- 今天第一次开通博客——希望帮助更多的人
- 关于".scf"文件与找回丢失的显示桌面图标
- 如何找回Win7丢失的搜索功能以便快速查找文件
- 从今天开始混csdn 希望各路高手照顾下我这个小菜鸟
- MySQL密码丢失的找回方法(win/*inx)
- suse10虚拟机root 密码丢失找回
- 十九、看数据科学家是如何找回丢失的数据的(一)
- "从今天起,我们一年级生,充满希望... ..."
- windows xp启动用户丢失,如何找回?
- WinXP 找回桌面丢失的IE图标(非IE快捷方式)
- Windows登陆密码丢失后的史上最简单的找回方法
- 只为今天(转)希望之源
- 重启linux 找回丢失的eth0
- MySQL密码丢失的找回方法
- OPPO手机丢失如何找回?