Program to convert temperature from fahrenheit to celsius

Assignment Help JAVA Programming
Reference no: EM131591338

For this assignment, you will be modifying the exercises from the previous assignment.

Change them to use a keyboard scanner instead of hard-coding values.

Use the nextLine() and parsing technique

We need to use the scanner
import java.util.Scanner;

Then created a keyboard reader

Scanner keyboard = new Scanner(System.in)

Write a Java program to convert temperature from Fahrenheit to Celsius.
public static void main(String[] args) {
double fahrenheit = 123.45;
double celcius = ((5 * (fahrenheit - 32.0)) / 9.0);

System.out.println("Exercise #1");
System.out.println(fahrenheit + "F is " + celcius + "C");
Output:
Exercise #1
Enter Fahrenheit: 123.45
123.45F is 50.80555555555556C
Exercise 2
Write a Java program that converts inches to meters
Use double variables inches and meters.
(One inch is 0.0254 meters)
public static void main(String[] Strings) {

Scanner input = new Scanner(System.in);

System.out.print("Input a value for inch: ");
double inch = input.nextDouble();
double meters = inch * 0.0254;
System.out.println("Exercise #2");
System.out.println(inch + " inch is " + meters + " meters");
Output:
Enter inches: 1000.0
1000.0 inches are 25.4 meters
Exercise 3
Concatenate first, middle, and last name
Create 3 Strings (firstName, middleInitial, and lastName)
Create 4th String variable named fullName and use the + operator to concatenate all parts of the name into one full name.
The user will input the data.
Enter your first name: Johhn
Enter your middle initial: J
Enter your last name: Jose

The full name is: John J. Jose
public static void main(String[] args) {
String fullName = "John J. Jose";
String lastName = fullName.substring(14);
System.out.println("Exercise #3");
System.out.println( "The full name is " + fullName);
Write a Java program to demonstrate the Java arithmetic operators
Name the integer variables x and y. That's okay to have single letter variables for this small demonstration.
Input x and y from the keyboard
Write the appropriate code to give this output:
public static void main(String args[]) {
int x = 11;
int y = 5;
System.out.println("Exercise #4");
System.out.println("11 + 5 = " + (x + y) );
System.out.println("11 - 5 = " + (x - y) );
System.out.println("5 - 11 = " + (y - x) );
System.out.println("11 * 5 = " + (x * y) );
System.out.println("11 / 5 = " + (x / y) );
System.out.println("11 % 5 = " + (x % y) );
}
Sample
Enter x: 12
Enter y: 6

12 + 6 = 18
12 - 6 = 6
6 - 12 = -6
12 * 6 = 72
12 / 6 = 2
12 % 6 = 0

Reference no: EM131591338

Questions Cloud

What is after-tax cost of the following preferred equity : What is the after-tax cost of the following preferred equity? The par value of the preferred share is $100 and the annual dividend is $7.00.
Identify some non quantitative factors : Straight Supply is a major supplier of medical components to large pharmaceutical corporations. Bonnie Straight is a second generation CEO of the company.
When is a method static and when is it not static : when is a method static and when is it not static? when is a method void and not void? what is a constructor in programming? can you explain this and give easy
Difference between the cash cycle and the operating cycle : What is the difference between the cash cycle and the operating cycle?
Program to convert temperature from fahrenheit to celsius : Write a Java program to convert temperature from Fahrenheit to Celsius - Change them to use a keyboard scanner instead of hard-coding values.
Explain the purpose of uninsured motorist coverage : Explain the purpose of Uninsured Motorist coverage? What is the major benefit of diversification? How does diversification work?
Java application using netbeans ide : Java application using NetBeans IDE to meet these additional and changed business requirements - java application should meet these technical requirements
Compute the present value-using the discount rates : Compute the present value of $1,050 paid in three years using the following discount rates:
Ci for her expected proportion of the vote : If, based on a sample size of 200, a political candidate found that 125 people would vote for her in a two-person race.

Reviews

Write a Review

JAVA Programming Questions & Answers

  Recursive factorial program

Write a class Array that encapsulates an array and provides bounds-checked access. Create a recursive factorial program that prompts the user for an integer N and writes out a series of equations representing the calculation of N!.

  Hunt the wumpus game

Reprot on Hunt the Wumpus Game has Source Code listing, screen captures and UML design here and also, may include Javadoc source here.

  Create a gui interface

Create GUI Interface in java programing with these function: Sort by last name and print all employees info, Sort by job title and print all employees info, Sort by weekly salary and print all employees info, search by job title and print that emp..

  Plot pois on a graph

Write a JAVA program that would get the locations of all the POIs from the file and plot them on a map.

  Write a university grading system in java

University grading system maintains number of tables to store, retrieve and manipulate student marks. Write a JAVA program that would simulate a number of cars.

  Wolves and sheep: design a game

This project is designed a game in java. you choose whether you'd like to write a wolf or a sheep agent. Then, you are assigned to either a "sheep" or a "wolf" team.

  Build a graphical user interface for displaying the image

Build a graphical user interface for displaying the image groups (= cluster) in JMJRST. Design and implement using a Swing interface.

  Determine the day of the week for new year''s day

This assignment contains a java project. Project evaluates the day of the week for New Year's Day.

  Write a java windowed application

Write a Java windowed application to do online quiz on general knowledge and the application also displays the quiz result.

  Input pairs of natural numbers

Java program to input pairs of natural numbers.

  Create classes implement java interface

Interface that contains a generic type. Create two classes that implement this interface.

  Java class, array, link list , generic class

These 14 questions covers java class, Array, link list , generic class.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd