1.write an algorithem and then ajava program that converts pounds in to kilogram
ID: 3621332 • Letter: 1
Question
1.write an algorithem and then ajava program that converts pounds in to kilograms . the programs prompts the user to enter a number in pounds , converts it to kilograms, and display the result. One pound is 0.454 kilograms.
2.write an algorathem and then program that reads from java consale the radius of a circle. Cululate and output the area and the perimeter of that circle. you can use the following formulas:
area= * r2 , Perimeter = 2**r.
3.write an algorithem and the java program that declars aminutes variable that represents minutes worked on ajob and reads avalue using Dialog Box .use time as the clas name Display the value in hours and minutes. for example 197mintes becomes 3 hours ad 17 minutes save the program as time java.
4. Write an algorithem aprogram that reads an integer between0 and 1000 and adds all the digits in the integer . for example if an integer is 932 the sum of all it is 14
hints ; use the % operator to extract digits and use the / operator to remove the extracted digits. for instance,932%10=2 and 932/10 =93
5.Write an algorthim ten ajava program that plays aword game with the user the program shoud ask the user to enter the following ;
His or her name
His or her age
the name of acity
the name of acollage
aprofession
after the user has entered there items the program should display the following story inserting the user's input into appropriate location.
there once was aperson name NAME who lived in CITY. at the age of AGE,NAME went to college at COLLEGE.NAME graduated and went to work as a PROFESSION
Explanation / Answer
2.Java program to find area and the perimeter of the circle
import javax.swing.JOptionPane;
public class Circle1
{
public static void main(String[] args)
{
// Declare variables
int radius;
double area;
double perimeter;
String inputStr =JOptionPane.showInputDialog("Enter Radius of circle: ");
radius = Integer.parseInt(inputStr);
// Compute area and perimeter
area = radius * radius * 3.1416;
perimeter = 2.0 * radius * 3.1416;
// Print results
System.out.print("The radius is ");
System.out.println(radius);
System.out.print("The area is ");
System.out.println(area);
System.out.print("The perimeter is ");
System.out.println(perimeter);
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.