Question

3. The following is the formula to convert a Celsius degree to Fahrenheit degree: Fahrenheit =...

3.

The following is the formula to convert a Celsius degree to Fahrenheit degree:

Fahrenheit = (9/5) Celsius + 32

Write a program to prompt user to enter a Celsius degree, convert it to Fahrenheit and display

  • Given an integer value which is the measurement of weight in ounce. Convert it to the format of: x pounds and y ounces. For example, if the given number is 100 ounces, it will be represented as 6 pounds and 4 ounces after conversion. Display message “z ounces = x pounds and y ounces”. x, y, z will be replaced by real values

(1 pound = 16 ounces)

This is meant to be written in Java 14.0

Homework Answers

Answer #1

import java.util.*;

public class Convert

{

    Scanner s= new Scanner(System.in);

    //function to conver celcius to farenheit

    void faren()

    {

        float f,c;

        //taking user input

        System.out.println("Enter the temperature in Celsius");

        c=s.nextFloat();

        //converting to farenheit

        // (9/5)=1.8

        f=(1.8f*c)+32;

        //displaying result

        System.out.println("The temperature in farenheit is: "+f);

    }

    //function to conver onces in pounds and ounces

    void pound()

    {

        int o,p,e;

        //taking user input

        System.out.println("\n\nEnter the weight in ounces");

        o=s.nextInt();

        //converting to pounds and ounces

        p=o/16;

        e=o%16;

        //displaying result

        System.out.println(o+" ounces = "+p+" pounds and "+e+" ounces");

    }

    public static void main(String[] args)

    {

        Convert x=new Convert();

        x.faren();

        x.pound();

    }

}

OUTPUT:

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
C++ Program: Prompt the user to enter a Fahrenheit degree then using the following formula to...
C++ Program: Prompt the user to enter a Fahrenheit degree then using the following formula to convert it to Celsius degree. Don't accept any value less than -60 and more than 200. C = (5/9)*(F – 32)
C++ Fahrenheit to Celsius Tables Write a program that first asks the user which Temperature scale...
C++ Fahrenheit to Celsius Tables Write a program that first asks the user which Temperature scale conversion he/she would like to perform: 1. Convert F to C 2. Convert C to F 3. Quit What is your choice? Then it asks the user for input for three real number variables: start_temp, end_temp, temp_incr. It will then produce a two column Fahrenheit to Celsius table or a two column Celsius to Fahrenheit table, depending on the choice. For choice 1, the...
Selection control structure The if statement The switch statement (optional) Relational operators and logical operators Use...
Selection control structure The if statement The switch statement (optional) Relational operators and logical operators Use of relational and logical operators to check numeric ranges User friendly Use of user friendly user prompt and simple input validation Use of meaningful output labels and format Use of output manipulators Working with string type Use of getline() Project Description There are two main systems for measuring distance, weight and temperature, the Imperial System of Measurement and the Metric System of Measurement. Most...
2. Write a java program to: Define 3 integer variables var4, var5, and var6. Initialize these...
2. Write a java program to: Define 3 integer variables var4, var5, and var6. Initialize these variables with numbers input from console Right shift values in var4, var5 and var6, so var6 will get var5’s value, var5 will get var4’s value and var4 will get var6’s value Calculate the average of these numbers and save it into variable avg Display the following message: “the average of numbers value4, value5 and value6 is average-value”. (value4, value5, value6 and average-value should be...