Question

JAVA PROGRAMMING 3. Fluid ounces to milliliters and gallons conversion: (a) read one double number vfloz...

JAVA PROGRAMMING

3. Fluid ounces to milliliters and gallons conversion:

(a) read one double number vfloz corresponding to some measurement in fluid ounces;

(b) convert it to milliliters and gallons;

(c) print out the results as floating point values.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

import java.util.*;

class Solution

{

    public static void main(String[] args)

    {

        Scanner sc = new Scanner(System.in);

       

        System.out.print("Enter the value in ounces : ");

        // read the value in ounce

        double vfloz = sc.nextDouble();

       

        // 1 ounce = 29.5735 milliliter

        double milliliter = vfloz * 29.5735;

       

        // 1 ounce = 0.0078125 gallon

        double gallon = vfloz * 0.0078125;

       

        System.out.println("\nMilliliter : " + milliliter);

        System.out.println("\nGallon: " + gallon);

    }

}

Sample Output

Enter the value in ounces : 25 Milliliter 739.3375 Gallon: 0.1953125

Add a comment
Know the answer?
Add Answer to:
JAVA PROGRAMMING 3. Fluid ounces to milliliters and gallons conversion: (a) read one double number vfloz...
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. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Read the entire document before starting to write code. Write and test a Java project that...

    Read the entire document before starting to write code. Write and test a Java project that satisfies the following requirements: Create a measurement converter project that can convert between units of price. (pounds and ounces). Use this table of conversion for your calculations. The constant for conversion is 1 pound = 16 ounces or 16 ounces = 1 pound Write a class definition file named UnitPriceConverter that has these fields and one constant. priceOfItem weightInPounds pricePerPound pricePerOunce constant: ouncesPerPound Write...

  • C++ programming language , I need help writing the code . Please explain if you can...

    C++ programming language , I need help writing the code . Please explain if you can . Exercise 10: Unit conversion (10 points) Write a console program that converts meters into feet and inches. The program starts by asking the user for a measurement in meters. The program should accept a floating point number. After getting the number, the program computes the number of feet and inches equal to the specified number of meters. The program outputs feet and inches...

  • (JAVA) Programming Assignment 3 There are a number of zoos available to tourists. 1. Create a...

    (JAVA) Programming Assignment 3 There are a number of zoos available to tourists. 1. Create a Zoo class. Include data fields such as name of zoo, location, size, fee for the past 12 months, number of visitors recorded for the past 12 months, admission rates per visitor and annual budget. (20 points) 2. Include at least two mutators and two accessors. (15 points) 3. Include one default constructor and one more constructor. (15 points) 4. Write separate instance methods that...

  • Use java programming for the following questions to have the solutions ready within today Jan 3...

    Use java programming for the following questions to have the solutions ready within today Jan 3 2020 at or before 7:00PM GMT+8 time zone: Question 13 Some service fees (% of asset amount) of two investment companies are shown in the following tables: Company A: Service Fee Type Fee Management Fee 1.5 Subscription Fee 5.0 Redemption Fee 1.0 Company B: Service Fee Type Fee Platform Fee 0.2 Management Fee 1.0 Subscription Fee 2.0 The above information is to be stored...

  • Need help with java programming. Here is what I need to do: Write a Java program...

    Need help with java programming. Here is what I need to do: Write a Java program that could help test programs that use text files. Your program will copy an input file to standard output, but whenever it sees a “$integer”, will replace that variable by a corresponding value in a 2ndfile, which will be called the “variable value file”. The requirements for the assignment: 1.     The input and variable value file are both text files that will be specified in...

  • Question 1 The following function header represents which programming language? double calc_weekly_pay( double hours_worked, double pay_rate)...

    Question 1 The following function header represents which programming language? double calc_weekly_pay( double hours_worked, double pay_rate) Question 1 options: Python A C-based language FORTRAN COBOL Question 2 One of my favorite quotes from Jeanette Wind is "Computational thinking is using abstraction and decomposition when attacking a large complex task or designing a large complex system." This supports using _____________ when developing programs. Question 2 options: Repetition structures Assignment statements Selection structures Functions Question 3 The following assignment statement exhibits which...

  • package _solution; /** This program demonstrates how numeric types and operators behave in Java Do Task...

    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 //identifier declarations final int NUMBER = 2 ; // number of scores int score1 = 100; // first test score int score2 = 95; // second test score final int BOILING_IN_F = 212; // boiling temperature double fToC;...

  • JAVA PROGRAMMING A complex number is a number in the form a + bi, where a...

    JAVA PROGRAMMING A complex number is a number in the form a + bi, where a and b are real numbers and i is V-1. The numbers a and b are known as the real part and imaginary part of the complex number, respectively. You can perform addition, subtraction, multiplication, and division for complex numbers using the following formulas: a + bi + c + di = (a + c) + (b + di a + bi - (c +...

  • C- PROGRAMMING PROJECT #4 Design and Write a C program to calculate an average of an...

    C- PROGRAMMING PROJECT #4 Design and Write a C program to calculate an average of an array of numbers and produce the following output: 1. Your first and last name 2. Course Number 3. C Project Number 4. All the numbers in the array 5. The sum of all the numbers in the array 6. The count of all the numbers in the array 7. The average of all the numbers in the array Double-space after lines 3, 4, 5,...

  • Java programming 1. Write a program that reads an unspecified number of integers, determines how many...

    Java programming 1. Write a program that reads an unspecified number of integers, determines how many positive and negative value have been read, and computes the total and average of the input values (not counting zeros. Your program ends with the input 0. Display the average as a floating point number Here are sample runs: (red indicates a user input) Enter an integer, the input ends if it is 0: 1 2 -1 3 0 The number of positives is...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT