Temperature Converter
converter from celsius to fahrenheit temperatures
int a = 6;
float b = 4;
float sub= (a - b);
System.out.println(sub);
import java.util.Scanner; //allows for user input
public class CelsiusFahrenheit {
public static void main(String[] args) {
String userInputStr;
double celsiusdouble, fahrenheitdouble;
boolean recommendationboolean;
Scanner inputStream = new Scanner(System.in); //creates area for input
System.out.print("What is your Celsius degrees? ");
userInputStr = inputStream.nextLine(); //assigns userinputstr as input
celsiusdouble = Double.parseDouble(userInputStr); //changes to stored variable celsiusdouble
System.out.print(celsiusdouble);
fahrenheitdouble = (celsiusdouble*1.8)+32; //set fahrenheit variable to conversion
System.out.print("\nFahrenheit conversion: " ); //enter line and print fahrenheit
System.out.print(fahrenheitdouble);
System.out.print ("\nYou would like an activity recommendation for that temperature? (answer true or false)");
userInputStr = inputStream.nextLine();
recommendationboolean = Boolean.parseBoolean(userInputStr);
if (recommendationboolean=true && celsiusdouble<=10) { //creates recommendation if wanted for specific temperature range
System.out.print("\nStay inside and read a book with hot chocolate");
} else if (recommendationboolean=true && celsiusdouble<=30 && celsiusdouble>10) {
System.out.print("\nGo on a hike outside with friends");
} else if (recommendationboolean=true && celsiusdouble>30) {
System.out.print("\nEat ice cream on the beach");
} else if (recommendationboolean=false) {
System.out.print("Have a nice day!");
}
}
}
CelsiusFahrenheit.main(null);