From ggc
Steps for solving the problem:
- Write a program that says "Add you code here."
- Revise to say "Welcome to Jam's Yogurt Shop."
- Revise to also say "How many ounces are in the first yogurt?"
- Read in the ounces, and report back what was put in
- Ask for second yogurt size and report back what was put in
- Report the total ounces
- Report the full price of the yogurt assuming no coupon
- Deduct the price of 8 ounces every time
- Deduct the price of 8 ounces only if they buy more than 16 ounces
- Report the price correctly if they buy 8 or more ounces
- Report the price for any ounces.
|
01 packagepackage is used to name the directory or folder a class is in jam;
02 importimport means to make the classes and/or packages available in this program java.util.*;
03 importimport means to make the classes and/or packages available in this program wiki.Wiki;
04 /**
05 * All about my application here.
06 * @authorthis is the Javadoc tag for documenting who created the source code Jam Jenkins
07 */
08 publicpublic is used to indicate unrestricted access (any other class can have access) classclass is a group of fields and methods used for making objects Yogurt
09 {open braces start code blocks and must be matched with a close brace
10 publicpublic is used to indicate unrestricted access (any other class can have access) staticstatic means that an instance is not required for access (class level access) voidvoid means the method does not return a value mainThe main method is the place where applications begin executing.(String[brackets are typically used to declare, initialize and index (indicate which element of) arrays]brackets are typically used to declare, initialize and index (indicate which element of) arrays args)
11 {open braces start code blocks and must be matched with a close brace
12 Wiki.out.println("Welcome to Jam's Yogurt Shop.");
13 Wiki.out.println("How many ounces are in the first yogurt?");
14 Scanner scanner=this assignment operator makes the left side equal to the right sidenewnew is used to create objects by calling the constructor Scanner(Wiki.in);
15 doubledouble is the type for numbers that can contain decimal fractions first=this assignment operator makes the left side equal to the right sidescanner.nextDouble();
16 Wiki.out.println("Your first yogurt is "+adds two numbers together or concatenates Strings togetherfirst+adds two numbers together or concatenates Strings together" ounces.");
17 Wiki.out.println("How many ounces are in the second yogurt?");
18 doubledouble is the type for numbers that can contain decimal fractions second=this assignment operator makes the left side equal to the right sidescanner.nextDouble();
19 Wiki.out.println("Your second yogurt is "+adds two numbers together or concatenates Strings togethersecond+adds two numbers together or concatenates Strings together" ounces.");
20 Wiki.out.println("Your yogurt total is "+adds two numbers together or concatenates Strings together(first+adds two numbers together or concatenates Strings togethersecond)+adds two numbers together or concatenates Strings together" ounces.");
21 doubledouble is the type for numbers that can contain decimal fractions price=this assignment operator makes the left side equal to the right side(first+adds two numbers together or concatenates Strings togethersecond)*0.39;
22 Wiki.out.println("Your cost is $"+adds two numbers together or concatenates Strings togetherprice);
23 }close braces end code blocks and must match an earlier open brace
24 }close braces end code blocks and must match an earlier open brace
|
Download/View jam/Yogurt.java