lab2--Question 2.

PHOTO EMBED

Mon Mar 27 2023 13:01:50 GMT+0000 (Coordinated Universal Time)

Saved by @Mohamedshariif #java

package com.mycompany.areaofcircle;

//import java.util.Scanner;
public class Areaofcircle {
    
    //Lab 2,   Question 2.

    public static void main(String[] args) {
        
        // Question 2.	Translate the following algorithm into Java code:
        
//   Step 1: Declare a double variable named miles with initial value 100.
//   Step 2: Declare a double constant named KILOMETERS_PER_MILE with value 1.609.
//   Step 3: Declare a double variable named kilometers, multiply miles and KILOMETERS_PER_MILE, and assign the result to kilometers. 
//   Step 4: Display kilometers to the console. 
//   What is kilometers after Step 4?

        
        double miles = 100;
        final double KILOMETERS_PER_MILE = 1.609;
        double kilometers;
        
        kilometers = miles * KILOMETERS_PER_MILE;
        
        System.out.println("kilometers is: "+kilometers);
        
        
    }
}
content_copyCOPY