Advanced Programming-Week3

Advanced Programming-Week3

Summary

  1. 输入 Scanner
    1. 输入整数 nextInt()
    2. 输入字符串 nextln()/next()
    3. 输入浮点数 nextDouble()

Task13

import java.util.*;
import javax.swing.*;
public class Task13 {
    public static void main(String []args)
    {
        int time;
        System.out.println("Please enter the time:");
        Scanner keybord=new Scanner(System.in);
        time=keybord.nextInt();
        int hh,mm;
        hh=time/60;
        mm=time%60;
        JOptionPane.showMessageDialog(null,String.format("The time is %02d hours %02d minuts",hh,mm),"time", -1);
    }
}

Task15

public class Task15 {
    public static void main (String [] args)
    {
        System.out.println("A\t"+5+4*3);
        System.out.println(5+4*3+"A\t");
        System.out.println(5*3+4+"A\t");
        System.out.println(5*3+"A\t"+4);
        System.out.print(5%3+"A\t"+4);
        System.out.print(3/4%4+2*5);
    }
}

Task16

import java.util.*;
public class Task16 {
    public static void main(String []args)
    {
        int origin;
        Scanner keybord=new Scanner(System.in);
        System.out.println("Please enter the num:");
        origin=keybord.nextInt();
        System.out.printf("The first num is %d\n",origin/100000);
        System.out.printf("The second num is %d\n",origin/10000%10);
        System.out.printf("The third num is %d\n",origin/1000%10);
        System.out.printf("The fourth num is %d\n",origin/100%10);
        System.out.printf("The fifth num is %d\n",origin/10%10);
        System.out.printf("The last num is %d",origin%10);
    }
}

Task17

import java.util.*;
public class Task17 {
    public static void main(String []args)
    {
        Scanner keybord=new Scanner(System.in);
        System.out.println("Please enter the age and the resting heart rate:");
        int a,r;
        a=keybord.nextInt();
        r=keybord.nextInt();
        System.out.printf("Your training heart rate is %d",7*(200-a)+3*r);
    }
}

Task18

import java.util.Scanner;
public class Task18 {
    public static void main(String []args)
    {
        int cyc_time;
        int jog_time;
        int swim_time;
        Scanner keybord = new Scanner(System.in);
        cyc_time=keybord.nextInt();
        jog_time=keybord.nextInt();
        swim_time=keybord.nextInt();
        System.out.printf("The pounds is %d",cyc_time*200+jog_time*475+swim_time*275);
    }
}

Task19

import java.util.Scanner;
public class Task19 {
    public static void main(String []args)
    {
        int num;
        Scanner keybord=new Scanner(System.in);
        num=keybord.nextInt();
        int n1,n2,n3,n4;
        n1=(num/1000+7)%10;
        n2=(num/100%10+7)%10;
        n3=(num/10%10+7)%10;
        n4=(num%10+7)%10;
        System.out.print("The new number is "+n3+n4+n1+n2);
    }
}

Task20

import java.util.Scanner;
public class Task20 {
    public static void main(String []args)
    {
        double c,pc,t,ar,s;
        Scanner keybord = new Scanner(System.in);
        c=keybord.nextDouble();
        pc=keybord.nextDouble();
        t=keybord.nextDouble();
        ar=keybord.nextDouble();
        s=keybord.nextDouble();
        System.out.println("Current Assets of ABC Limited");
        System.out.printf("\tCash\t\t\t%8.2f\n",c);
        System.out.printf("\tPetty Cash\t\t%8.2f\n",pc);
        System.out.printf("\tTemporary\t\t%8.2f\n",t);
        System.out.printf("\tInvestments\n");
        System.out.printf("\tAccounts receivable\t%8.2f\n",ar);
        System.out.printf("\tSupplies\t\t%8.2f\n",s);
    }
}

暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇