Java程序辅导

C C++ Java Python Processing编程在线培训 程序编写 软件开发 视频讲解

客服在线QQ:2653320439 微信:ittutor Email:itutor@qq.com
wx: cjtutor
QQ: 2653320439
CS 110 
Page 1 of 2 
Lab 1 
 
Your Name Your Partner's Name 
 
 
 
 
 
Table 1: Test Cases (hand calculated) 
Big Macs Eaten Calories Consumed Miles to Walk It Off 
0   
1   
3   
9   
 
Table 2: Your Program's Output 
Big Macs Eaten Calories Consumed Miles to Walk It Off 
0   
1   
3   
9   
 
Table 3: French Fry Test Cases (hand calculated) 
Big Macs Eaten French Fries Eaten Calories Consumed Miles to Walk It Off 
0 0 packages   
1 1 package   
3 2 packages   
9 7 packages   
 
Table 4: Your Program's Output 
Big Macs Eaten French Fries Eaten Calories Consumed Miles to Walk It Off 
0 0 packages   
1 1 package   
3 2 packages   
9 7 packages   
 
  Page 2 of 2 
 
Lab 1 Source Code 
 
 
import java.util.Scanner; 
 
   public class BurnItOff 
   { 
      public static void main(String[] args) 
      { 
       
      // Declare variables 
         double bigMacs = 0; 
         double caloriesConsumed = 0; 
         double milesToWalk = 0; 
       
      // Create a Scanner object 
         Scanner keyboard = new Scanner(System.in); 
       
      // Get the number of Big Macs eaten 
         System.out.print("How many Big Macs did you eat? "); 
         bigMacs = keyboard.nextDouble(); 
       
      // Calculate the claories consumed and the miles to burn it off 
         caloriesConsumed = bigMacs * 590; 
         milesToWalk = caloriesConsumed / 93.5; 
       
      // Display the results 
         System.out.println("Wow, you consumed " + caloriesConsumed + " calories"); 
         System.out.println("You need to walk " + milesToWalk + " miles"); 
      } 
   }