第三次作业
import java.util.Scanner; public class work1 { public static void main(String[] args) { Scanner input=new Scanner(System.in); System.out.println("请输入商品单价"); int price=input.nextInt(); System.out.println("请输入商品数量"); int count=input.nextInt(); int sum=price*count; System.out.println("商品总价是"+sum); double discount=sum*0.8; System.out.println("商品活动价是"+discount); System.out.println("请输入付款金额"); int payment=input.nextInt(); double change=payment-discount; System.out.println("找零"+change); } }
import java.util.Scanner; public class work2 { public static void main(String[] args) { Scanner input=new Scanner(System.in); System.out.println("请输入一个三位数"); int a=input.nextInt(); int b,c,d; d=a%10; System.out.println("个位上的数是"+d); c=a/10%10; System.out.println("十位上的数是"+c); b=a/100; System.out.println("百位上的数是"+b); } }
import java.util.Scanner; public class work3 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.println("请输入字符串:"); String character = sc.nextLine(); char[] r=character.toCharArray(); for (int i = 0; i < r.length; i++) { if ((int)r[i] >= 65 && (int)r[i] <= 90) { r[i] += 32; } else if ((int)r[i] >= 97 && (int)r[i] <= 122) { r[i] -= 32; } } for (int i = 0; i < r.length; i++) { System.out.print(r[i]+" "); } } }
import java.util.Scanner; public class work4 { public static void main(String[] args) { Scanner input=new Scanner(System.in); System.out.println("输入第一个数"); int a=input.nextInt(); System.out.println("输入第二个数"); int b=input.nextInt(); int c; c=a>b?a:b; System.out.println("最大值为"+c); } }