Created
September 28, 2017 13:50
-
-
Save peterhynes/50ab54914044e4f1d43d19ed83c0f4b2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| ClothesShopCalc.java | |
| @ Peter Hynes | |
| 28th Sept | |
| */ | |
| //Scanner class - Utility package import | |
| import java.util.*; | |
| //class signature | |
| public class ClothesShopCalc{ | |
| //main method | |
| public static void main(String args[]){ | |
| //declare and assign variables | |
| double tshirts=5.99; | |
| double shorts=10.99; | |
| double socks=3.99; | |
| double coat=20.50; | |
| int nooftshirts=0; | |
| int noofshorts=0; | |
| int noofsocks=0; | |
| int noofcoats=0; | |
| double total=0; | |
| //object - bring in scanner class and give it the name "keyboard" | |
| Scanner keyboard; | |
| keyboard=new Scanner(System.in); | |
| //print stock + price | |
| System.out.println("Stock List"); | |
| System.out.println("T-Shirt Price "+tshirts); | |
| System.out.println("Shorts Price "+shorts); | |
| System.out.println("Socks Price "+socks); | |
| System.out.println("Coat Price "+coat); | |
| //input - ask a question - how many of each item woud the user like | |
| System.out.println("How many T-Shirts would you like?"); | |
| nooftshirts=keyboard.nextInt(); | |
| System.out.println("How many pairs of Shorts would you like?"); | |
| noofshorts=keyboard.nextInt(); | |
| System.out.println("How many pairs of socks would you like?"); | |
| noofsocks=keyboard.nextInt(); | |
| System.out.println("How many coats would you like?"); | |
| noofcoats=keyboard.nextInt(); | |
| //process total | |
| total=(nooftshirts*tshirts)+(noofshorts*shorts)+(noofsocks*socks)+(noofcoats*coat); | |
| //output - print total | |
| System.out.println("Your total is "+total); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment