P
phuthanvinh
Guest
I wrote this project with code, unsure
public class Project1
{
public static void main(String[] args) // Declarations
{
Scanner scan = new Scanner( System.in); // Scanner class to read the data from the system.in
int Tokyo; // read the number of input
System.out.print("Please enter the temperature for Tokyo in Celsius: ");
Tokyo = scan.nextInt();
System.out.println("The temperature of Tokyo in Celsius is: " + Tokyo + "C" );
int Nepal;
System.out.print("Please enter the temperature for Nepal in Celsius: ");
Nepal = scan.nextInt();
System.out.println("The temperature of Nepal in Celsius is: " + Nepal + "C" );
int Bethlehem;
System.out.print("Please enter the temperature for Bethlehem in Fahrenheit: ");
Bethlehem = scan.nextInt();
System.out.println("The temperature of Bethlehem in Fahrenheit is: " + Bethlehem + "F" );
int Sa;
System.out.print("Please enter the temperature for South Africa in Fahrenheit: ");
Sa = scan.nextInt();
System.out.println("The temperature of South Africa in Fahrenheit is: " + Sa + "F" );
// Convert values
TokyoD = (Tokyo * (9.0/5.0)) + 32;
NepalD = (Nepal * (9.0/5.0)) + 32;
BethlehemD = (Bethlehem-32) * (5.0/9.0);
SaD = (Sa-32) * (5.0/9.0);
Double Tokyo2 = ((double)Tokyo * (9.0/5.0)) + 32;
Double Nepal2 = ( (double)Nepal * (9.0/5.0)) + 32;
Double Bethlehem2 = ((double)Bethlehem-32) * ( 5.0/9.0);
Double Sa2 = ((double)Sa-32) * (5.0/9.0);
// Print information
System.out.println("Tokyo " + Tokyo + "C\nNepal " + Nepal + "C\nBethlehem " + Bethlehem + "F\nSouth Africa " + Sa + "F");
System.out.println();
// Print both fahrenheit and celcius for each location
System.out.println("Tokyo " + (double)Tokyo + "C " + TokyoD + "F");
System.out.println ("Rome " + (double)Nepal + "C " + NepalD + "F");
System.out.println("Athens " + BethlehemD + "C " + (double)Bethlehem + "F");
System.out.println ("Auckland " + SaD + "C " + (double)Sa + "F");
}
} //End of program.
public class Project1
{
public static void main(String[] args) // Declarations
{
Scanner scan = new Scanner( System.in); // Scanner class to read the data from the system.in
int Tokyo; // read the number of input
System.out.print("Please enter the temperature for Tokyo in Celsius: ");
Tokyo = scan.nextInt();
System.out.println("The temperature of Tokyo in Celsius is: " + Tokyo + "C" );
int Nepal;
System.out.print("Please enter the temperature for Nepal in Celsius: ");
Nepal = scan.nextInt();
System.out.println("The temperature of Nepal in Celsius is: " + Nepal + "C" );
int Bethlehem;
System.out.print("Please enter the temperature for Bethlehem in Fahrenheit: ");
Bethlehem = scan.nextInt();
System.out.println("The temperature of Bethlehem in Fahrenheit is: " + Bethlehem + "F" );
int Sa;
System.out.print("Please enter the temperature for South Africa in Fahrenheit: ");
Sa = scan.nextInt();
System.out.println("The temperature of South Africa in Fahrenheit is: " + Sa + "F" );
// Convert values
TokyoD = (Tokyo * (9.0/5.0)) + 32;
NepalD = (Nepal * (9.0/5.0)) + 32;
BethlehemD = (Bethlehem-32) * (5.0/9.0);
SaD = (Sa-32) * (5.0/9.0);
Double Tokyo2 = ((double)Tokyo * (9.0/5.0)) + 32;
Double Nepal2 = ( (double)Nepal * (9.0/5.0)) + 32;
Double Bethlehem2 = ((double)Bethlehem-32) * ( 5.0/9.0);
Double Sa2 = ((double)Sa-32) * (5.0/9.0);
// Print information
System.out.println("Tokyo " + Tokyo + "C\nNepal " + Nepal + "C\nBethlehem " + Bethlehem + "F\nSouth Africa " + Sa + "F");
System.out.println();
// Print both fahrenheit and celcius for each location
System.out.println("Tokyo " + (double)Tokyo + "C " + TokyoD + "F");
System.out.println ("Rome " + (double)Nepal + "C " + NepalD + "F");
System.out.println("Athens " + BethlehemD + "C " + (double)Bethlehem + "F");
System.out.println ("Auckland " + SaD + "C " + (double)Sa + "F");
}
} //End of program.




