java基础案例 2-1

java基础案例 2-1
商品入口
要求 1.控制台录入信息
2.有以下内容:品牌型号,尺寸,价格,配置,库存,总价

代码如下:

package com.ithema.spedkey;

import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入产品型号: ");
        int cp = sc.nextInt();
        //数字

        System.out.println("请输入尺寸:");
        String cc =  sc.next();
        //字符串
    
        System.out.println("请输入价格:");
        int jg = sc.nextInt();
        //数字
    
        System.out.println("请输入配置:");
        String pz =  sc.next();
        //字符串
    
        System.out.println("请输入库存:");
        int kc = sc.nextInt();
        //数字
    
        System.out.println("请输入总价:");
        int zj = sc.nextInt();
        //数字
    
        System.out.println("产品型号是:" +cp);
        System.out.println("尺寸是:" +cc);
        System.out.println("价格是:" +cc);
        System.out.println("配置是:" +pz);
        System.out.println("库存是:" +kc);
        System.out.println("总价是:" +zj);
    }
}
版权属于:张芷豪 本文链接:https://zzh.xn--fiqs8s/index.php/archives/194/ 转载申明:转载请保留本文转载地址,著作权归作者所有。

评论

等风等雨等你来
Title - Artist
0:00