Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Ch 2 Conversion Problems This set of problems involves converting a value in a o

ID: 670673 • Letter: C

Question

Ch 2 Conversion Problems

This set of problems involves converting a value in a one unit to a value in another unit. Each program should prompt the user for a value in the specified units and then print the converted value along with the new units. Save each program separately in one folder, zip up the folder and turn it in on Blackboard/Learn under the Extra Credit Conversions Ch2 assignment. Add error checking to each exercise below for an added 0.5 points credit (0.5 points total, not 0.5 points each).

Write a program to converts miles to kilometers. ( 1 mile = 1.6093440 km ) Ask the user for the number of miles including decimal values.

Write a program to converts meters to miles. Ask the user for the number of meters including decimal values. Print your output in scientific notation using the proper conversion specifier in your printf statement. ( 1 m = 0.00062137119 miles )

Write a program to converts pounds to kilograms. Ask the user for the number of pounds including decimal values. ( 1 kg = 2.205 lbs. )

Write a program to convert Newtons to pounds. Ask the user for the Newtons including decimal values. ( 1 lb. = 4.448 N )

Write a program that converts degrees Fahrenheit (Tf) to degrees Rankin (Tr). (Tf = Tr – 459.67r)

Write a program that converts degrees Celsius (Tc) to degrees Rankin (Tr). (Tf = 9/5 * Tc + 32f)

Write a program that converts degrees Kelvin (Tk) to degrees Fahrenheit (Tf). (Tr = 9/5*Tk, and Tf = Tr – 459.67r)

Explanation / Answer

Solution 1:

import java.io.*;
public class mileToKilo {
public static void main(String[] args) throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.print("Enter the number of miles : ");
double miles = Double.parseDouble(br.readLine());
double km = miles*1.6093440 ;
System.out.println("Distance in kilometres is : "+km);
}
}

Solution 2:

import java.io.*;
public class metreToMile{
public static void main(String[] args) throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.print("Enter the number of metres : ");
double metre = Double.parseDouble(br.readLine());
double mile = metre*0.00062137119 ;
System.out.println("Distance in miles is : "+mile);
}
}

Solution 3:

import java.io.*;
public class poundsToKg{
public static void main(String[] args) throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.print("Enter the number of pounds : ");
double pound = Double.parseDouble(br.readLine());
double kg = pound*0.453592;
System.out.println("Weight in kilograms is : "+kg);
}
}

Solution 4:

import java.io.*;
public class newtonToPound{
public static void main(String[] args) throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.print("Enter the force in Newtons : ");
double newton = Double.parseDouble(br.readLine());
double lb = newton*0.224808943 ;
System.out.println("Force in pounds is : "+lb);
}
}

Solution 5:

import java.io.*;
public class farenToRank{
public static void main(String[] args) throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.print("Enter the temperature in fahrenheit : ");
double fh = Double.parseDouble(br.readLine());
double rank = fh+459.67 ;
System.out.println("Temperature in rankine is : "+rank);
}
}

Solution 6:

import java.io.*;
public class celToRank{
public static void main(String[] args) throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.print("Enter the temperature in degree celsius : ");
double cs = Double.parseDouble(br.readLine());
double rank = cs+493.47 ;
System.out.println("Temperature in rankine is : "+rank);
}
}

Solution 7:

import java.io.*;
public class kelviToFah{
public static void main(String[] args) throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.print("Enter the temperature in Kelvin : ");
double kl = Double.parseDouble(br.readLine());
double fah = kl-457.87 ;
System.out.println("Temperature in fahrenheit is : "+fah);
}
}