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
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT