Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Implement the following integer methods: A. Method celsius returns the Celsius e

ID: 3582016 • Letter: I

Question

Implement the following integer methods: A. Method celsius returns the Celsius equivalent of a Fahrenheit temperature, sign the calculation B. Method fahrenheit returns the Fahrenheit equivalent of a Celsius temperature using the calculation C. Use the methods from parts (A) and (B) to write an application that enables the user either to enter a Fahrenheit temperature and display the Celsius equivalent or to enter a Celsius temperature and display the Fahrenheit equivalent.

Write a program that will help elementary school students learn multiplication. Use a random object to produce two positive one-digit integers. The program should then prompt the user with a question, such as How much is 6 times 7 ? The student then inputs the answer. Next, the program checks the student’s answer. If it is correct, display the message “Very good!” and ask another multiplication question. If the answer is wrong, display the message “No. Please try again.” and let the student try the same question repeatedly until the student finally gets it right. A separate method should be used to generate each new question. This method should be called once when the application begins execution and each time the user answers the question correctly.

Below is what I have so far

import java.util.Scanner; public class Multiply
{
Random randomNumbers = new Random(); int answer
public void quiz()
{
Scanner input = new Scanner(System.in); int guess;
/* Write code to call method checkResponse to display the question*/ System.out.println(“Enter your answer (-1 to quit):”);
guess = input.nextInt(); while (guess!=-1)
{
/* Write code to call the method to check user’s answer*/ System.out.println(“Enter your answer (-1 to quit):”); guess = input.nextInt();
}
}
/* Write a method header for createQuestion method*/
{
/* Write code to get 2 random numbers. Write code to multiply the two numbers and store the result in variable answer */
}
/* Method to check if user answered correctly*/
{
/* Write code to test whether the answer is incorrect. If it is incorrect tell the user to try again */
}
}

Explanation / Answer

package snippet;

import java.io.*;
import java.text.DecimalFormat;
import java.util.Scanner;

public class Temparature {

  
   public static double Celsius(double f)
   {double c;
   c = ((f - 32) * 5) / 9;
   return c;
     
   }
  
   public static double Fahrenheit (double c)
   {
   double f = (9 * c / 5) + 32;
   return f;
     
   }
public static void main(String args[]) throws IOException {
Double c, f;
Scanner sc=new Scanner(System.in);
  
while(true)
{
           System.out.println("1)Enter F to convert to Fahrenheit 2)Enter C to convert to Celsius ");
           String ch;
           ch=sc.next();
             
           System.out.println("Enter temperature ");
           double temp;
           temp=sc.nextDouble();
             
          
          
           switch (ch)
           {
           case "F":
          
          
           c=Celsius(temp);
           System.out.println( c+"C");
           break;
           case "C":
          
               f=Fahrenheit(temp);
           System.out.println(f+"F");
           break;
          
           }
}
}
}

=========================================================

Output:

1)Enter F to convert to Fahrenheit
2)Enter C to convert to Celsius

F
Enter temperature

95
35.0C

======================================================================

package snippet;

import java.util.Random;
import java.util.Scanner;

class Multiply
{
   Random randomNumbers = new Random();
   int answer;
public static void quiz()
{
Scanner input = new Scanner(System.in);
int guess;
/* Write code to call method checkResponse to display the question*/
int ans=createQuestion();
System.out.println("Enter your answer -1 to quit:");
guess = input.nextInt();
           while (guess!=-1)
           {
           /* Write code to call the method to check user’s answer*/
              
               Check(guess,ans);
               System.out.println("Enter your answer (-1 to quit):");
               guess = input.nextInt();
           }
}
/* Write a method header for createQuestion method*/
public static int createQuestion()
{Random random = new Random();
   int a=(int)random.nextInt(9);
   int b=(int)random.nextInt(9);
   System.out.println("How much is "+a+" times "+b);
   int ans=a*b;
   return ans;
/* Write code to get 2 random numbers. Write code to multiply the two numbers and store the result in variable answer */
}
/* Method to check if user answered correctly*/
public static int Check(int userans,int ans)
{
/* Write code to test whether the answer is incorrect. If it is incorrect tell the user to try again */
   if(userans==ans)
   {
       System.out.println("Very good!");
       return 1;
   }
   else
   {
       System.out.println("No. Please try again");
       return 0;
   }
  
}

public static void main(String []args)
{
   quiz();
}
}

=============================================================================

Output:

How much is 0 times 6
Enter your answer -1 to quit:
12
No. Please try again
Enter your answer (-1 to quit):
32
No. Please try again
Enter your answer (-1 to quit):
0
Very good!
Enter your answer (-1 to quit):