Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

import java.util.Scanner; //package _solution; /** This program demonstrates how numeric types and operators behave in Java Do Task #1 before adding Task#2 where indicated. */

import java.util.Scanner;

//package _solution;

/**

This program demonstrates how numeric types and operators behave in Java

Do Task #1 before adding Task#2 where indicated.

*/

public class NumericTypesOriginal {

public static void main (String [] args) {

//TASK #2 Create a Scanner object here

Scanner keyboard = new Scanner (System.in);

//identifier declarations

final int NUMBER = 2 ; // number of scores

double score1; // first test score

double score2; // second test score

final int BOILING_IN_F = 212; // boiling temperature

double fToC; // temperature in Celsius

double average; // arithmetic average

String output; // line of output to print out

//Task #2 declare a variable to hold the users temperature

double inputTemp;

//Task #2 prompt user to input score1

System.out.print("What is the first score? ");

//Task #2 read score1

score1 = keyboard.nextDouble();

//Task #2 prompt user to input score2

System.out.print("What is the second score? ");

//Task #2 read score2

score2 = keyboard.nextDouble();

// Find an arithmetic average

average = (score1 + score2) / NUMBER;

output = score1 + " and " + score2 + " have an average of " + average;

System.out.println(output);

// Convert Fahrenheit temperatures to Celsius

fToC = (5/9) * (BOILING_IN_F - 32);

output = BOILING_IN_F + " in Fahrenheit is " + fToC + " in Celsius.";

System.out.println(output);

//Task #2 prompt user to input another temperature

System.out.print("Enter a temperature in Fahrenheit ");

//Task #2 read the users temperature in Fahrenheit

inputTemp = keyboard.nextDouble();

//Task #2 convert the users temperature to Celsius

fToC = (5/9) * (inputTemp - 32);

//Task #2 print the users temperature in Celsius

output = inputTemp + " in Fahrenheit is " + fToC + " in Celsius.";

System.out.println(output);

System.out.println("Goodbye"); // to show that the program is ended

}

}

This is my code so far, but I can't find the mistake in the conversion of Fahrenheit to Celsius

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Semantics In Databases Second International Workshop Dagstuhl Castle Germany January 2001 Revised Papers Lncs 2582

Authors: Leopoldo Bertossi ,Gyula O.H. Katona ,Klaus-Dieter Schewe ,Bernhard Thalheim

2003rd Edition

3540009574, 978-3540009573

More Books

Students also viewed these Databases questions

Question

3. Is IBMs program really a mentoring program? Why or why not?

Answered: 1 week ago