SDUT JAVA lab2.4

简介: SDUT JAVA lab2.4

7-4 sdut-JAVA-the number of pounds worked off

分数 10

全屏浏览

切换布局

作者 马新娟

单位 山东理工大学

The number of calories burned per hour by cycling, jogging, and swimming are 200, 475, and 275, respectively. A person loses 1 pound of weight for each 3500 calories burned. Write a program that declares three variables, one to store the number of hours spent jogging, the second to store the number of hours spent cycling and the third to store the number of hours spent swimming. Assign each of these variables values. Calculate and display the number of pounds worked off.

Input Specification:

declares three variables, one to store the number of hours spent jogging, the second to store the number of hours spent cycling and the third to store the number of hours spent swimming.

Output Specification:

display the number of pounds worked off.

Sample Input:

3.5
5
4.15

Sample Output:

Total calories burned = 3803.75.
Pounds lost = 1.0867857142857142.

代码长度限制

16 KB

时间限制

400 ms

内存限制

64 MB

栈限制

8192 KB

import java.util.Scanner;
public class Main
{   public static void main(String [] args)
    {
        Scanner in =new Scanner(System.in);
        double hoursSpentJogging = in.nextDouble();
        double hoursSpentCycling = in.nextDouble();
        double hoursSpentSwimming = in.nextDouble();
        double totalCaloriesBurned=(200*hoursSpentCycling)+(475*hoursSpentJogging)+(275*hoursSpentSwimming);
        double poundsLost=totalCaloriesBurned/3500;
        String r ="Total calories burned = " + totalCaloriesBurned + ".\n";
        r += "Pounds lost = " + poundsLost + ".";
        System.out.println(r);
    }
}


目录
相关文章
|
1月前
|
Java
SDUT java lab 7.3
SDUT java lab 7.3
19 0
|
1月前
|
Java
sdut java lab 7.1(法二好理解)
sdut java lab 7.1(法二好理解)
37 1
|
1月前
|
Java 应用服务中间件 AHAS
sdut java lab6主观题
sdut java lab6主观题
22 0
|
1月前
|
人工智能 Java
sdut java lab5
sdut java lab5
25 0
|
1月前
|
Java
sdut java lab7.2(法二)
sdut java lab7.2(法二)
28 0
|
1月前
|
存储 Java
SDUT java lab7.4
SDUT java lab7.4
21 0
|
1月前
|
Java
SDUT JAVA lab3.9
SDUT JAVA lab3.9
32 2
|
1月前
|
Java
SDUT Java lab6
SDUT Java lab6
12 0
|
1月前
|
Java
sdut java lab7单选
sdut java lab7单选
25 0
|
1月前
|
存储 Java 索引
sdut java lab 7.6
sdut java lab 7.6
26 0