150k views
0 votes
Write a java program that accepts the ingredients for a recipe in cups and converts to ounces

User Ahmed Imam
by
4.9k points

1 Answer

3 votes

Answer:

Step-by-step explanation:

public static int cupsToOunces (int cups) {

int ounces = cups * 8;

return ounces;

}

This is a very simple Java method that takes in the number of cups in the recipe as a parameter, converts it to ounces, and then returns the number of ounces. It is very simple since 1 cup is equal to 8 ounces, therefore it simply takes the cups and multiplies it by 8 and saves that value in an int variable called ounces.

User Pchajer
by
4.4k points