//* the code is supposed to take temperature calulations and im running into iss
ID: 3733263 • Letter: #
Question
//* the code is supposed to take temperature calulations and im running into issues getting the if statments to register. PLEASE help*//
//*/* CallingMethodsInSameClass.java
*
* illustrates how to call static methods a class
* from a method in the same class
*/
import java.util.Scanner;
public class Conversions
{
public static void main(String[] args) {
double a,b,d,e,f;
int z=1;
int y =2;
Scanner in= new Scanner(System.in);
int c = in.nextInt();
System.out.println("Conversion Prog Fahreheit to Celcius, Press 1 then Enter Celcius to Fahreheit, Select 2 then enter key ");
a= in.nextDouble();
System.out.println(" Enter Temp in WholeNumber.DecimalValue Format");
if ( c=z){
d=celciusTemp(a);
System.out.println(" The Converted value is: "+ d);
return;
}
else {
if ( c=y){
d=fahrTemp(a);
System.out.println(" The Converted Value is: "+ d);
return;
}
}
}
public static double celciusTemp(double a1) {
double a2 = (9/5)* a1 +32;
return a2;
}
public static double fahrTemp(double b1) {
double b2= (b1-32)*(5/9);
return b2;
}
}
*//
Explanation / Answer
Hi
I have fixed the issues
Conversions.java
import java.util.Scanner;
public class Conversions
{
public static void main(String[] args) {
double a,d;
int z=1;
int y =2;
Scanner in= new Scanner(System.in);
System.out.println("Conversion Prog Fahreheit to Celcius, Press 1 then Enter Celcius to Fahreheit, Select 2 then enter key ");
int c = in.nextInt();
System.out.println(" Enter Temp in WholeNumber.DecimalValue Format");
a= in.nextDouble();
if ( c==z){
d=celciusTemp(a);
System.out.println(" The Converted value is: "+ d);
return;
}
else {
if ( c==y){
d=fahrTemp(a);
System.out.println(" The Converted Value is: "+ d);
return;
}
}
}
public static double celciusTemp(double a1) {
double a2 = (9/5)* a1 +32;
return a2;
}
public static double fahrTemp(double b1) {
double b2= (b1-32)*(5/9);
return b2;
}
}
Output:
Conversion Prog
Fahreheit to Celcius, Press 1 then Enter
Celcius to Fahreheit, Select 2 then enter key
1
Enter Temp in
WholeNumber.DecimalValue
Format
22.22
The Converted value is:
54.22
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.