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); } }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter