C HANGES (P ROG 600 – 58 T ) AP Computer Science 2010 By: Chia-Hsuan Wu.

Slides:



Advertisements
Similar presentations
Chapter 6 Problem Solving and Algorithm Design. 2 Phase Interactions.
Advertisements

1 Chapter 2 Introduction to Java Applications Introduction Java application programming Display ____________________ Obtain information from the.
Today’s topics: I/O (Input/Output). Scribbler Inputs & Outputs  What are the Scribbler’s inputs and outputs?  reset button  motors/wheel  light sensor.
Identify and state the value of a penny, nickel, dime, quarter Level 1 CLICK HERE TO START LEVEL 1.
Hand Crafting your own program By Eric Davis for CS103.
CS 112 Intro to Computer Science II Sami Rollins Fall 2006.
In Class Exercises. TV  Think about your television as an object.  You send messages to it using the remote control. What messages can you send?  What.
Loops Chapter 4. It repeats a set of statements while a condition is true. while (condition) { execute these statements; } “while” structures.
1 Lab 2 CSIT-120 Fall 2000 Session II-A (September 14th) Operations on Data Lab Exercise 2-A Data Types Variables Lab Exercise 2-B Session II-B (September.
Lets Count Money!!! Kelly Goolsby. Content Area: Math Grade Level: 2nd Summary: The purpose of this instructional power point is to teach students how.
LAB 10.
1 Interactive Applications (CLI) Interactive Applications Command Line Interfaces Project 1: Calculating BMI Example: Factoring the Solution Reading for.
Computer Programming Lab(5).
Money Introduction Lesson Quiz Introduction Basic information In order to begin this lesson you need to know a few things. One dollar bills=1 Five.
Counting Currency For Special Education K-12 Next Slide.
I wonder who has more money…. 1 dollar, 3 nickels, 5 dimes 6 dimes, 3 pennies, 5 quarters 8 pennies, 6 nickels, 3 dimes 2 half dollars, 5 pennies, 8 nickels.
CSC 1051 M.A. Papalaskari, Villanova University Repetition CSC 1051 – Data Structures and Algorithms I Dr. Mary-Angela Papalaskari Department of Computing.
Input & Output In Java. Input & Output It is very complicated for a computer to show how information is processed. Although a computer is very good at.
U.S CURRENCY By: Danielle Ritter. DIRECTIONS Next Back Home.
CSC 1051 – Data Structures and Algorithms I Dr. Mary-Angela Papalaskari Department of Computing Sciences Villanova University Course website:
Money By: Rachel Morello Teacher Page Click here!
Can we talk?. In Hello World we already saw how to do Standard Output. You simply use the command line System.out.println(“text”); There are different.
Penny Nickel Dime Penny Nickel Dime Quarter Half Dollar.
Counting Coins. The Basics Quarter 25 cents Dime 10 cents.
MONEY! Pick the correct coin! Click here to get started!!
 M2N1. Students will use multiple representations of numbers to connect symbols to quantities  c. Use money as a medium of exchange. Make change and.
Outline Creating Objects The String Class The Random and Math Classes Formatting Output Enumerated Types Wrapper Classes Components and Containers Images.
CSci 111 – computer Science I Fall 2014 Cynthia Zickos WRITING A SIMPLE PROGRAM IN JAVA.
CSC 1051 – Data Structures and Algorithms I Dr. Mary-Angela Papalaskari Department of Computing Sciences Villanova University Course website:
1 By Mrs. Stephanie Estes. 2 Tyler spent 7 dollars and 4 dimes for school supplies. Write this amount with a dollar sign and decimal point. $7.40.
Name the United States Coins Count the Pennies 10 ¢
MATH AND MONEY.
String and Scanner CS 21a: Introduction to Computing I First Semester,
CS110 Programming Language I Lab 4: Control Statements I Computer Science Department Spring 2014.
Outline Character Strings Variables and Assignment Primitive Data Types Expressions Data Conversion Interactive Programs Graphics Applets Drawing Shapes.
CSC 1051 – Data Structures and Algorithms I Dr. Mary-Angela Papalaskari Department of Computing Sciences Villanova University Course website:
Introduction Chapter 1 8/31 & 9/1 Imagine! Java: Programming Concepts in Context by Frank M. Carrano, (c) Pearson Education - Prentice Hall, 2010.
CSC 1051 – Data Structures and Algorithms I Dr. Mary-Angela Papalaskari Department of Computing Sciences Villanova University Course website:
CSC 1051 M.A. Papalaskari, Villanova University Algorithms Dr. Mary-Angela Papalaskari Department of Computing Sciences Villanova University Course website:
CSC 1051 – Algorithms and Data Structures I Dr. Mary-Angela Papalaskari Department of Computing Sciences Villanova University Course website:
CSC 1051 – Data Structures and Algorithms I Dr. Mary-Angela Papalaskari Department of Computing Sciences Villanova University Course website:
Making Change For a Dollar By Jessica Willison. Mathematics Lesson 1 st Grade.
Week 2 Definitions Assignment Expressions Input. Variables Usually when problem solving multiple things need determining Without the ability to remember.
Counting Quarters, Dimes, Nickels, and Pennies Click here to begin Click here to begin.
Martin T. Press.  Main Method and Class Name  Printing To Screen  Scanner.
import java.util.Scanner; class myCode { public static void main(String[] args) { Scanner input= new Scanner(System.in); int num1; System.out.println(“Enter.
Array Review Selection Sort Get out your notes.. Learning Objectives Be able to dry run programs that use arrays Be able to dry run programs that use.
CASHIERING REVIEW Are you ready for the test?. LET’S FIND OUT! Question #1 Who is ultimately responsible for all financial transactions? A.The Cashier.
HOW CAN I CONVERT MONEY? MCC.4.MD.1 Money. Conversions ____ pennies = 1 nickel ____ nickels = 1 dime ____ dimes = 1 dollar ____ quarters = 1 dollar.
CSC 1051 – Data Structures and Algorithms I Dr. Mary-Angela Papalaskari Department of Computing Sciences Villanova University Course website:
Chapter 2 Clarifications
CSC111 Quick Revision.
Exercise : Write a program that print the final price of purchase at a store where everything costs exactly one dollar. Ask for the number of items purchased.
Chapter 2 More on Math More on Input
TemperatureConversion
CSC1401 Input and Output (and we’ll do a bit more on class creation)
Money    By: Kaitlin and Chloe.
Chapter 6 More Conditionals and Loops
Maha AlSaif Maryam AlQattan
CASHIERING.
OUTPUT STATEMENTS GC 201.
INPUT STATEMENTS GC 201.
Introduction to Classes and Methods
Introduction to Computer Science and Object-Oriented Programming
Name the United States Coins
CASHIERING.
Module 3 Selection Structures 4/5/2019 CSE 1321 Module 3.
CSC 111 Exam 3 Review Fall 2005.
Computer Science Club 1st November 2019.
Presentation transcript:

C HANGES (P ROG 600 – 58 T ) AP Computer Science 2010 By: Chia-Hsuan Wu

S O, HERE IS YOUR MISSION Write a class that will direct a cashier on how much change to give customer. The program should have two inputs : The amount of the purchase and the amount received from the customer and a call to the calculate method. The class methods will determine and output the number of dollars, quarters, dimes, nickels and pennies need to make the correct change for the transaction. The class will also print out a table of each type of coin/currency to return to the customer. Be sure to use lookup tables for the values of your coins and the monetary denominations.

G ETTING R EADY … Start by importing these two: - import java.io.*; - import java.util.Scanner; Then the usual: public class Prog60058t { public static void main (String [] args) { } create a scanner so user can input amount. Scanner i = new Scanner (System.in);

C ONTACTING T OWER … Print a line of text “Enter purchase price “ then create a value (double) for the user to enter System.out.print (“Enter purchase price “); double x = i.nextDouble (); Repeat the action above and print “Enter amount given “ and assign a value to it. Then from print out (different lines): “ ” “Correct change “ “ ”

T AKING O FF … Then create another value that calculate the difference of y and x (price and given). double TT = y – x; Convert it into int. int EST = (int)TT; EST is the amount of ONE DOLLAR BILL you’ll be giving. So print out the amount of ones System.out.println (“Ones = “ + EST); Then create another value called “Left” to calculate the decimal value of TT double Left = TT – EST; //Decimal Then create another value DL that will times Left to 100. (so we don’t have to deal with ugly decimal numbers!) double DL = (Left*100);

I N T HE A IR …H OLY COW ! Y OU FORGOT THE FLIGHT INSTRUCTIONS. ( GOTTA FIGURE IT OUT !) Create If statement to determine the number of each coin. First of all, check if DL is >= to 25. (if DL is >= 25 that means you will need to hand out quarters.) YOU MUST CHECK ALL POSSIBILITIES

H INT 1: I check if DL >= 25 If yes then check if DL >= 77 and 50 If no then check if DL >= 10 If yes then divide DL by 10 and make it in int. And that’s the number of dimes If no then same thing with nickels and pennies.

No Check if DL is >= 25 YES Check if DL >= 50 YES No Print quarter = 1. Then DL – 25 Check if DL is >=10 YesNo Hint 2: Solution on the next page

P ROBLEM S OLVED. R EADY TO LAND. S OLUTION : Great job! That sure took a while. Alright here is my solution: Remember : it is not the only solution.

C ONGRATULATIONS ! S UCCESSFUL L ANDED ! Final part of this program is to print out the total amount So… System.out.println (“Total Amount = “ + TT); Don’t forget to try the program before you finished It should look like this: Enter purchase price Enter amount given Correct Change Ones = 9 Quarters = 3 Dimes = 2 Nickels = 0 Pennies = 4.0 Total Amount = 9.99

THE END THANK YOU FOR YOUR TIME.