Hi, I have to code a java program that accepts the ingredients for a recipe in cups and converts to ounces. I started off coding but I got stuck. I need to know if I'm on the right track or not.  import java.util.Scanner; public class Chp4_Project{ public static void main(String[] args) {Scanner input = new Scanner(System.in); System.out.print("Enter the first ingredient: ");String ingred1 = input.nextLine(); System.out.print("Enter the second ingredient: ");String ingred2 = input.nextLine(); System.out.print("Enter the third ingredient: ");String ingred3 = input.nextLine();   Our input is to name three ingredients and the number of cups for each.  And then the output should have two lines of :1. The names of the ingredients in the following format. The items inside < > are variables.The recipe uses <ingredient 1>, <ingredient 2>, and <ingredient 3>2. The total volume of all three ingredients in ounces in the following format. The item inside < > is a variable.The total amount of the recipe in ounces is <total ounces>  I really want to understand and get this without seeming like I'm only looking for the answers.

Question
Asked Oct 10, 2019
108 views

Hi, I have to code a java program that accepts the ingredients for a recipe in cups and converts to ounces.

 

I started off coding but I got stuck. I need to know if I'm on the right track or not. 

 

import java.util.Scanner;
 
public class Chp4_Project
{
 
public static void main(String[] args)
 
{
Scanner input = new Scanner(System.in);
 
System.out.print("Enter the first ingredient: ");
String ingred1 = input.nextLine();
 
System.out.print("Enter the second ingredient: ");
String ingred2 = input.nextLine();
 
System.out.print("Enter the third ingredient: ");
String ingred3 = input.nextLine();
 
 

 Our input is to name three ingredients and the number of cups for each. 

 

And then the output should have two lines of :

1. The names of the ingredients in the following format. The items inside < > are variables.
The recipe uses <ingredient 1>, <ingredient 2>, and <ingredient 3>
2. The total volume of all three ingredients in ounces in the following format. The item inside < > is a variable.
The total amount of the recipe in ounces is <total ounces>
 
 
I really want to understand and get this without seeming like I'm only looking for the answers. 
check_circle

Expert Answer

star
star
star
star
star
1 Rating
Step 1
  • Create a class and a class method which will calculate the number of ounce from the number of cups (for per ingredient).
  • In method totalOunce() it will calculate the number of ounces required and return to the main method.
  • In main method take inputs from user 1st ingredients and the number of cups required for that ing...

Want to see the full answer?

See Solution

Check out a sample Q&A here.

Want to see this answer and more?

Solutions are written by subject experts who are available 24/7. Questions are typically answered within 1 hour.*

See Solution
*Response times may vary by subject and question.
Tagged in

Engineering

Computer Science

Java

Related Computer Science Q&A

Find answers to questions asked by student like you
Show more Q&A
add
question_answer

Q: I am changing careers and avoided math my entire academic life. Can you please tell me what math is ...

A: Importance of math in web development:For beginners, both arithmetic and basic algebra should be min...

question_answer

Q: in python Create a new Python program (you choose the filename) that contains a main function and an...

A: Create a main function in the program.Create an empty list, the name of the list is randomNumber.Use...

question_answer

Q: Recall the following code, which we examined in class.v o i d f o r k t e s t ( ){p r i n t f ( ” mo...

A: The sample output of the given program is:

question_answer

Q: Code should be in C++ Absolute Value Template: Write a function template that accepts an argument an...

A: Since Function Templates are used to handle all possible data types you can say generic data type at...

question_answer

Q: Driving is expensive. Write a program with a car's miles/gallon and gas dollars/gallon (both doubles...

A: Program Instructions:Take car's miles/gallon and gas dollars/gallon as input using scanner class.Cal...

question_answer

Q: 1. /15 points] Consider the following function: Func1(A, n) * A is an array of integers 1 80; 2 for ...

A: a)Worst case running time of Func1:The random number between 1 to “n” is assigned to “k” in the give...

question_answer

Q: Using the following truth table, write the equivalent Boolean equations in Sum of Product and Produc...

A: Simplification of Sum Of Products (SOP):The truth table of the SOP is as follows

question_answer

Q: The following data fragment occurs in the middle of a data stream for which the byte-stuffing algori...

A: Byte stuffing algorithm, also referred as Character stuffing algorithm was invented to overcome the ...

question_answer

Q: What are some apps you use regularly? Why? What makes you choose to use them over other apps that do...

A: There are many apps that we use regularly. The most commonly used apps includes the following:Educat...