{% highlight java %} /** * --------------------------------------------------------------------------- * File name: MathExercises.java * Project name: Study Guide * --------------------------------------------------------------------------- * Author’s name and email: Michael Schneider, schneidm@etsu.edu * Course-Section: All * Creation Date: 12/15/15 * Last modified: Schneider 12/15/15 schneidm@etsu.edu * --------------------------------------------------------------------------- */ /** * Class Name: Math Exercises
* Class Purpose: To provide practical exercises in using Java's math operators.
* *
* Date created: 12/15/15
* Last modified: Schneider 12/15/15 schneidm@etsu.edu * @author Michael Schneider */ public class MathExercises{ public static void main(String[] args){ /******************************************************* * * Examples * ********************************************************/ //Declare a numeric variable and initialize it with a value int startingValue = 5; //Use the addition operator and the compound addition operator to addition //10 your variable. startingValue = startingValue + 10; startingValue += 10; //Declare and initialize a whole number and decimal number variables int whole = 17; double decimal = 17.0; //Divide each variable by 3 whole /= 3; decimal = decimal / 3; //Display the results System.out.println("Whole: " + whole); System.out.println("Decimal: " + decimal); /******************************************************* * * Practice Problems * ********************************************************/ // Problem 1: Create appropriate variables to solve the problem // You are creating a program to calculate total shipping weight for your packages. // Your packages can contain any of the following items: // - Coffee beans (5 lbs) // - Coffee filters (3.5 lbs) // - Purified water (25 lbs) // How much will a package weight if it contains 4 orders of coffee beans, // 6 orders of coffee filters, and 2 containers of purified water? // Display your results to the screen //Problem 2 : If shipping costs $3.75 per lbs, how much will your shipment cost? // Display your results to the screen //Problem 3 : If half of your shipment is lost, what is new shipping weight and // new cost for shipping? Display your results to the screen } } {% endhighlight %}