栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

2022 06 02 Java学习课后练习

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

2022 06 02 Java学习课后练习

#作业 20220602
源代码

import java.math.BigDecimal;
import java.util.Scanner;
public class Work02{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 作业1、从键盘输入3个数,求最大值
		System.out.println("作业一");
		String enter = "请输入一个整数数字";

		System.out.print(enter);				
		int numberOne = sc.nextInt(); // 第一个输入的数
		System.out.println();
		System.out.print(enter);
		int numberTwo = sc.nextInt(); // 第二个输入的数
		System.out.println();
		System.out.print(enter);
		int numberThree = sc.nextInt(); // 第三个输入的数
		
		boolean   f1 =  (numberOne >numberTwo && numberOne > numberThree); 
		boolean   f2 =  (numberOne < numberThree && numberTwo < numberThree);
		System.out.println();
			
		if( f1== true ){
			System.out.println("你输入最大的数是"+numberOne);
		}
		else if( f2== true ){
			System.out.println("你输入最大的数是"+numberThree);
		}
		else{
			System.out.println("你输入最大的数是"+numberTwo);
		}
		System.out.println("nnn");



		// 作业2、模拟取款,输入取款金额,如果余额够,显示余额;否则提示余额不足。
		System.out.println("作业二");
		double  money =78901.26;
		BigDecimal bDecimal =new BigDecimal(money);

		System.out.println("请输入取款金额:");
		int witMon = sc.nextInt();
		
		if( money >= witMon ){
			System.out.println("当前账户余额:");
			System.out.println(money);
			System.out.println("是否继续当前操作:");
			System.out.print("继续请按1");
			System.out.print("放弃请按0");
			int w = sc.nextInt();
			if( w == 1 ){
				System.out.println("当前账户余额:");
				System.out.println((money-(double)witMon));
				
			}else{
				System.out.println("即将返回主页面,请稍后!");
			}
		}
		else{
			System.out.println("当前账户余额不足!");
		}
		System.out.println("nnn");

		
		System.out.println("作业三");
		System.out.println("我:我想买车!");
		System.out.println("导购员:您想什么价位的车!");
		 int hwoMon = sc.nextInt();
		System.out.println("我:我有"+hwoMon+"万的预算");
		if( hwoMon > 500 ){
			System.out.println("导购员:我觉得卡迪拉克和您很配!");
		}else{ 	if( hwoMon > 100 ){
				System.out.println("导购员:您有开帕萨特的气质!");
			}else{ 	
				if( hwoMon > 50 ){
					System.out.println("导购员:你的预算买卡伊兰特性价比最高!");
				}else{ 	
					if( hwoMon > 10 ){
						System.out.println("导购员:那我跟你介绍一下这款奥拓!");
					}else{
						System.out.println("导购员:捷安特性能杠杠的!!!考虑一下");
					 }
				}
			}
		}
		System.out.println("nnn");

		
		System.out.println("从天涯到海角票价是:RMB5000元" );
		int price = 5000; 
		System.out.println("出行日期:9102 - (  请输入月份!!! )");
		int month = sc.nextInt();
		System.out.println("选择头等舱请输入1经济舱请输2:");
		int engRoom = sc.nextInt();
		if(month >= 4 && month <= 10){
			if(engRoom==1){
				System.out.println("你的票价是" + (price-price/10) );
			}else{
				System.out.println("你的票价是" + (price-2*price/10) );
			}
		
		}else {
			if(month < 13  &&  month > 0){
				if(engRoom==1){
					System.out.println("你的票价是" + (price-5*price/10) );
				}else{
					System.out.println("你的票价是" + (price-4*price/10) );
				}
			
			}else{
				System.out.println("我觉得您更适合待在家里!!!");
			}
		}
		

		
	
	}
}




转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/952973.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号