(Convert feet into maters) Write a program that reads a number in feet, converts
ID: 3844546 • Letter: #
Question
(Convert feet into maters) Write a program that reads a number in feet, converts it to meters, and displays the result. One foot theta 0.3 theta 5 motor. Hero is a sample run: (Convert pounds into kilograms) Write a program that converts pounds into kilograms. The program prompts the user to enter a number in pounds, converts it to kilograms, and displays the result. One pound is theta.454 kilograms. Here is a sample run: (Sum the digits in an integer) Write a program that reads an integer between e and 1000 and adds all the digits in the integer. For example, if an integer is 932, the sum of all its digits is 14. (Physics: acceleration) Average acceleration is defined as the change of velocity divided by the time taken to make the change, as shown in the following formula: a = v_1 - v_2/t Write a program that prompts the user to enter the starting velocity v_0 in meters/second, the ending velocity v, in meters/second, and the time span t in seconds, and displays the average acceleration. Here is a sample run: (Science: wind - chill temperature) How cold is it outside? The temperature alone is not enough to provide the answer. Other factors including wind speed, relative humidity, and sunshine play important roles in determining coldness outside. In 2001, the National Weather Service (NWS) Implemented the new wind - chill temperature to measure the coldness using temperature and wind speed The formula is t_wc = 35.74 + 0.6215 t - 35.75 v degree + 0.4275 t where t is the outside temperature measured in degrees Fahrenheit and v is the speed measured in miles per hour, t_wc is the wind-chill temperature. The formula cannot be used for wind speeds below 2 mph or temperatures below -58 degree F or above 41 degree w F. Write a program that prompts the user to enter a temperature between -58 degree F and 41 degree F and a wind speed greater than or equal to 2 and displays the wind - chill temperature. Use Math. pow (a, b) to compute Here is a sample run:Explanation / Answer
1. Code is below
import java.util.Scanner;
public class HelloWorld{
public static void main(String []args){
// taking user input
Scanner sc = new Scanner(System.in);
System.out.print("Enter a value for feet: ");
float f = sc.nextFloat();
// multiplying with 0.305 and printing
System.out.println(f+" feet is "+f*0.305+" meters");
}
}
Sample Output
Enter a falue for feet: 16.5
16.5 feet is 5.0325 meters
2. Code is below
import java.util.Scanner;
public class HelloWorld{
public static void main(String []args){
// taking user input
Scanner sc = new Scanner(System.in);
System.out.print("Enter a number in pounds: ");
float f = sc.nextFloat();
// multiplying with 0.454 and printing
System.out.println(f+" feet is "+f*0.454+" meters");
}
}
Sample Output
Enter a number in pounds: 55.5
55.5 feet is 25.197 meters
3. Code is below
import java.util.Scanner;
public class HelloWorld{
public static void main(String []args){
// taking user input
Scanner sc = new Scanner(System.in);
System.out.print("Enter an integer between 0 and 1000: ");
int n = sc.nextInt();
int sum = 0, copy = n;
// running loop as long as n is greater than 0
while(n > 0)
{
// summing up the last digit of n
sum = sum + n%10;
// dividing n by 10 so that last digit will be gone
n = n/10;
}
// printing the output
System.out.println("The sum of all digits in "+ copy + " is "+ sum);
}
}
Sample Output
Enter an integer between 0 and 1000: 435
The sum of all digits in 435 is 12
4. Code is below
import java.util.Scanner;
public class HelloWorld{
public static void main(String []args){
// taking user input
Scanner sc = new Scanner(System.in);
System.out.print("Enter v0, v1 and t: ");
float v0, v1, t, acc;
v0 = sc.nextFloat();
v1 = sc.nextFloat();
t = sc.nextFloat();
// calculating acceleration
acc = (v1-v0)/t;
// printing acceleration
System.out.println("The average acceleration is "+acc);
}
}
Sample Output
Enter v0, v1 and t: 5.5 50.9 4.5
The average acceleration is 10.088889
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.