Please i need some help with this assigment in Java Java Pro

Please i need some help with this assigment in Java!

Java Programming
(Assignment 6 – Classes/Objects)

You will use your knowledge of Java programming to create your first object oriented program.

Concepts Learned
•   Classes
•   Constructors
•   Objects – calling
•   Objects - creating

Spec

In your first object oriented programming assignment, you will create a temperature converter program. There will be a total of 4 classes/objects. The first will be called Fahrenheit. The second class will be called Celsius. The third class will be called Kelvin . The fourth class will be called Temperature Converter. The Temperature Converter class will have a main, none of the rest will.

Fahrenheit Class
•   Create a constructor that prints “Fahrenheit class created”
•   will contain a method that converts a Fahrenheit temperature to Celsius (returns double)
•   will contain a method that converts a Fahrenheit temperature to Kelvin (returns double)
•   Overload the toString method to say “Fahrenheit class”

Celsius Class
•   Create a constructor that prints “Celsius class created”
•   will contain a method that converts a Celsius temperature to Fahrenheit (returns double)
•   will contain a method that converts a Celsius temperature to Kelvin (returns double)
•   Overload the toString method to say “Celsius class”

Kelvin Class
•   Create a constructor that prints “Kelvin class created”
•   will contain a method that converts a Kelvin temperature to Fahrenheit (returns double)
•   will contain a method that converts a Kelvin temperature to Celsius (returns double)
•   Overload the toString method to say “Kelvin class”

Temperature Converter Class
•   Contains a main
•   Create three objects – Fahrenheit obj, Celsius obj, Kelvin obj
•   Welcome user to Temperature converter program
•   Ask user to pick which temperature format they would like use (ie, Fahrenheit, Celsius, Kelvin)
•   Call the toString method of the temperature format picked
•   Ask user to pick which temperature format they would like to convert to (ie, Fahrenheit, Celsius, Kelvin)
•   Call the toString method of the temperature format picked
•   Ask user to enter temperature (double)
•   Convert the temperature entered by using the proper obj and method
•   The conversion should be printed

Test Cases
1.   User will pick Fahrenheit and convert to Celsius. Temp entered 89.6
2.   User will pick Celsius and convert to Fahrenheit. Temp entered 32.0
3.   User will pick Kelvin and convert to Celsius. Temp entered 295.5
4.   User will pick Kelvin and convert to Fahrenheit. Temp entered 305.5
Please submit the screenshot of these cases.

Submission
Submit the assignment in the assignments area in blackboard where you retrieved this assignment originally. You must submit a screenshot of the output and directed comments. If you have issues with the code, please print it out and submit it in class.

Solution

import java.util.Scanner;


public class TemperatureConverter {

   /**
   * @param args
   */
   public static void main(String[] args) {
       Fahrenheit fahrenheit= new Fahrenheit();
       Celsius celsius= new Celsius();
       Kelvin kelvin= new Kelvin();
       System.out.println(\"Welcome user to Temperature converter program\");
       Scanner scan= new Scanner(System.in);
       int choice;
       double temp;
       System.out.println(\"Pick your temparature format\");
       System.out.println(\"1) Fahrenheit\");
       System.out.println(\"2) Celsius\");
       System.out.println(\"3) Kelvin\");
       choice=scan.nextInt();
      
       switch (choice) {
       case 1:
           fahrenheit.toString();
           System.out.println(\"Enter the temperature\");
           temp=scan.nextDouble();
           System.out.println(\"Fahrenheit: \"+temp+\" is Celsius: \"+fahrenheit.FahrenheitToCelsius(temp));
           System.out.println(\"Fahrenheit: \"+temp+\" is Kelvin: \"+fahrenheit.FahrenheitToKelvin(temp));
           break;
       case 2:
           celsius.toString();
           System.out.println(\"Enter the temperature\");
           temp=scan.nextDouble();
           System.out.println(\"Celsius: \"+temp+\" is Fahrenheit: \"+celsius.CelsiusToFahrenheit(temp));
           System.out.println(\"Celsius: \"+temp+\" is Kelvin: \"+celsius.CelsiusToKelvin(temp));
           break;
       case 3:
           kelvin.toString();
           System.out.println(\"Enter the temperature\");
           temp=scan.nextDouble();
           System.out.println(\"Kelvin: \"+temp+\" is Celsius: \"+kelvin.KelvinToCelsius(temp));
           System.out.println(\"Kelvin: \"+temp+\" is Fahrenheit: \"+kelvin.KelvinToFahrenheit(temp));
           break;
       default:
           System.out.println(\"Wrong Choice!!\");
           break;
       }
      
   }

}

class Fahrenheit{
   public Fahrenheit() {
       System.out.println(\"Fahrenheit class created\");
   }
  
   public double FahrenheitToCelsius(double F){
       return (F - 32) * 5/9;
      
   }
  
   public double FahrenheitToKelvin(double F){
       return 60*F + 459.67;
      
   }
  
   @Override
   public String toString() {
       // TODO Auto-generated method stub
       System.out.println(\"Fahrenheit class\");
       return \"Fahrenheit class\";
   }
  
}

class Celsius{
   public Celsius() {
       System.out.println(\"Celsius class created\");
   }
  
   public double CelsiusToFahrenheit(double C){
       return 9 * (C / 5) + 32;
      
   }
  
   public double CelsiusToKelvin(double C){
       return C + 273.15;
      
   }
  
   @Override
   public String toString() {
       System.out.println(\"Celsius class\");
       return \"Celsius class\";
   }
  
}

class Kelvin{
  
   public Kelvin() {
       System.out.println(\"Kelvin class created\");
   }
  
   public double KelvinToFahrenheit(double K){
       return K* 9/5 - 459.67;
      
   }
  
   public double KelvinToCelsius(double K){
       return K - 273.15;
      
   }
  
   @Override
   public String toString() {
       System.out.println(\"Kelvin class\");
       return \"Kelvin class\";
   }
  
}

-------output--------
Fahrenheit class created
Celsius class created
Kelvin class created
Welcome user to Temperature converter program
Pick your temparature format
1) Fahrenheit
2) Celsius
3) Kelvin
1
Fahrenheit class
Enter the temperature
89.6
Fahrenheit: 89.6 is Celsius: 32.0
Fahrenheit: 89.6 is Kelvin: 5835.67

Fahrenheit class created
Celsius class created
Kelvin class created
Welcome user to Temperature converter program
Pick your temparature format
1) Fahrenheit
2) Celsius
3) Kelvin
2
Celsius class
Enter the temperature
32.0
Celsius: 32.0 is Fahrenheit: 89.6
Celsius: 32.0 is Kelvin: 305.15


Fahrenheit class created
Celsius class created
Kelvin class created
Welcome user to Temperature converter program
Pick your temparature format
1) Fahrenheit
2) Celsius
3) Kelvin
3
Kelvin class
Enter the temperature
295.5
Kelvin: 295.5 is Celsius: 22.350000000000023
Kelvin: 295.5 is Fahrenheit: 72.22999999999996

Fahrenheit class created
Celsius class created
Kelvin class created
Welcome user to Temperature converter program
Pick your temparature format
1) Fahrenheit
2) Celsius
3) Kelvin
3
Kelvin class
Enter the temperature
305.5
Kelvin: 305.5 is Celsius: 32.35000000000002
Kelvin: 305.5 is Fahrenheit: 90.22999999999996


-------output--------

Note: please put the above file in on single file in java. Please feel free to ask doubts/queries. God bless you!

Please i need some help with this assigment in Java! Java Programming (Assignment 6 – Classes/Objects) You will use your knowledge of Java programming to create
Please i need some help with this assigment in Java! Java Programming (Assignment 6 – Classes/Objects) You will use your knowledge of Java programming to create
Please i need some help with this assigment in Java! Java Programming (Assignment 6 – Classes/Objects) You will use your knowledge of Java programming to create
Please i need some help with this assigment in Java! Java Programming (Assignment 6 – Classes/Objects) You will use your knowledge of Java programming to create
Please i need some help with this assigment in Java! Java Programming (Assignment 6 – Classes/Objects) You will use your knowledge of Java programming to create

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site