on netbean Objectives One of the primary objectives of this practice assignment
ID: 3602636 • Letter: O
Question
on netbean
Objectives
One of the primary objectives of this practice assignment is for you to get your Java programming environment up and running. You have three alternatives for the environment (see the Alternative Software Announcement):
Download and install NetBeans
Use the NetBeans desktop on Citrix
Use Eclipse (either your own copy, or the copy on Citrix)
Make sure you view the Media Gallery on accessing Citrix and downloading installing NetBeans.
Let's practice writing some Java methods and refresh our programming skills!
Post your Solutions to the Discussion Forum
When you complete these programs post them (use a new post for each program) in the Practice Programs and Programming Help Discussion forum.
Practice 1
Write a program that accepts a distance in kilometers, sends it to a method which converts it to miles, and then displays the result. The formula for conversion is Miles = Kilometers * 0.6214
Practice 2
Insurance companies suggest that people should insure a building for at least 80 percent of the cost to replace it. Write a program that accepts the cost of a building, sends it to a method which calculates the recommended insurance, and then displays the result in a currency format.
can you show screen shots where the codes go
Explanation / Answer
KilometerToMiles.java
import java.util.Scanner;
public class KilometerToMiles {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
System.out.println("Enter the distance in kilometers: ");
double k = scan.nextDouble();
convertToMiles(k);
}
public static void convertToMiles(double Kilometers){
double Miles = Kilometers * 0.6214;
System.out.println("Miles: "+Miles);
}
}
Output:
Enter the distance in kilometers:
4.5
Miles: 2.7962999999999996
BuildingCost.java
import java.util.Scanner;
public class BuildingCost {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
System.out.println("Enter the cost of building: ");
double cost = scan.nextDouble();
findInsurance(cost);
}
public static void findInsurance(double cost) {
double insurance = (cost * 80)/100;
System.out.printf("Insurance: $%.2f ",insurance);
}
}
Output:
Enter the cost of building:
10000
Insurance: $8000.00
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.