@AdamChen3/

Jenny's coding lab 3

Java

No description

fork
loading
Files
  • Main.java
Main.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
// Import Scanner
import java.util.Scanner;
class Main {
  // Create your Scanner here.
static Scanner scan = new Scanner(System.in);
  public static void main(String[] args) {
    
    
    // Uncomment each point version below as you start it.
    System.out.println(run50PointVersion());
    // System.out.println(run60PointVersion());
    // System.out.println(run70PointVersion());
    // System.out.println(run80PointVersion());
    // System.out.println(run90PointVersion());
    // System.out.println(run95PointVersion());
    // System.out.println(run100PointVersion());
  }
 public static double run50PointVersion(){
    // Write your code for the 50 point version below.  Be sure to stay above the next comment.
    System.out.println("Please enter km:");
    double km = scan.nextDouble();
    double miles = (km / 1.609);
    
    
    // Do not edit the following line, except to uncomment it when you start this point verison.
    // return miles;
    
 }

  public static double run60PointVersion(){
    // Write your code for the 60 point version below.  Be sure to stay above the next comment.
    System.out.println("Please enter grams: ");
      double g = scan.nextDouble();
    double ounces = (g / 28.35);
    
    // Do not edit the following line, except to uncomment it when you start this point verison.
    // return ounces;
    
  }
  
  public static double run70PointVersion(){
    // Write your code for the 70 point version below.  Be sure to stay above the next comment.
    System.out.println("Please enter milliliters: ");
      double mL = scan.nextDouble();
    double fluidOunces = (mL / 29.574);
    
    // Do not edit the following line, except to uncomment it when you start this point verison.
    // return fluidOunces;
  
  }
  
  public static double run80PointVersion(){
    // Write your code for the 80 point version below.  Be sure to stay above the next comment.
    System.out.println("Please enter centimeters: ");
     double cm = scan.nextDouble();
    double inches  = (cm / 2.54);
    
    // Do not edit the following line, except to uncomment it when you start this point verison.
    // return inches;
  
  }
  
  public static double run90PointVersion(){
    // Write your code for the 90 point version below.  Be sure to stay above the next comment.
    System.out.println("Please enter celsius: ");
    double celsius = scan.nextDouble();
    double fahrenheit  = ((celsius * 9) / 5 + 32);
    
    // Do not edit the following line, except to uncomment it when you start this point verison.
    // return fahrenheit;
  
  }
  
  public static String run95PointVersion(){
    // Write your code for the 95 point version below.  Be sure to stay above the next comment.
    System.out.println("Please enter total seconds: ");
    double totalSeconds = scan.nextDouble();
    double hours = Math.floor(totalSeconds / 3600);
    double minutes = Math.floor((totalSeconds / 60) - (hours * 60));
    double remainingseconds = totalSeconds - ((Math.floor((totalSeconds / 60) - (hours * 60))) * 60+(hours * 3600));
    
    // Do not edit the following lines, except to uncomment the "result +=" lines when you are ready to test. (Ctrl + /)
    // String result = "";
    // result += "Hours:\t\t" + hours + "\n";
    // result += "Minutes:\t" + minutes + "\n";
    // result += "Seconds:\t" + remainingseconds + "\n";
    // return result;
  }
  public static String run100PointVersion(){
    // Write your code for the 100 point version below.  Be sure to stay above the next comment.
    System.out.println("Please enter total milliseconds: ");
    double totalMilliseconds = scan.nextDouble();
    double hours = Math.floor(totalMilliseconds / 3600000);
    double minutes = Math.floor((totalMilliseconds / 60000) - (hours * 60));
    double seconds = Math.floor(totalMilliseconds / 1000) - ((Math.floor((totalMilliseconds / 60000) - (hours * 60)) * 60) + (hours * 3600));
    double remainingMilliseconds = totalMilliseconds - ((((Math.floor(totalMilliseconds / 1000) - ((Math.floor((totalMilliseconds / 60000) - (hours * 60)) * 60) + (hours * 3600))*1000) + (Math.floor((totalMilliseconds / 60000) - (hours * 60))*60000) + (Math.floor(totalMilliseconds / 3600000)*3600000)))*1000);;;
    
    // Do not edit the following lines, except to uncomment the "result +=" lines when you are ready to test. (Ctrl + /)
    String result = "";
    result += "Hours:\t\t" + hours + "\n";
    result += "Minutes:\t" + minutes + "\n";
    result += "Seconds:\t" + seconds + "\n";
    result += "Milliseconds:\t" + remainingMilliseconds + "\n";
    return result;
  }
}