math operators and a challenge mastery objectives: students will— be able to use augment...
TRANSCRIPT
![Page 1: Math operators and a challenge Mastery Objectives: Students will— Be able to use augment assignment operators Demonstrate proficiency in using types, variables](https://reader036.vdocuments.us/reader036/viewer/2022071709/56649d145503460f949e8a3f/html5/thumbnails/1.jpg)
Math operators and a challenge
Mastery Objectives: Students will—• Be able to use augment assignment operatorsDemonstrate proficiency in using types, variables
and simple i/O
![Page 2: Math operators and a challenge Mastery Objectives: Students will— Be able to use augment assignment operators Demonstrate proficiency in using types, variables](https://reader036.vdocuments.us/reader036/viewer/2022071709/56649d145503460f949e8a3f/html5/thumbnails/2.jpg)
Augmented assignment operators
• Another way to write a math calculation• Less code, harder to read
![Page 3: Math operators and a challenge Mastery Objectives: Students will— Be able to use augment assignment operators Demonstrate proficiency in using types, variables](https://reader036.vdocuments.us/reader036/viewer/2022071709/56649d145503460f949e8a3f/html5/thumbnails/3.jpg)
Useful Augment Assignment Operators
Operator Example Equivalent*= x*=5
x=x*5/= x/=5
x=x/2%= x%=5 x=x%5+= x+=5
x=x+5-= x-=5
x=x-5
![Page 4: Math operators and a challenge Mastery Objectives: Students will— Be able to use augment assignment operators Demonstrate proficiency in using types, variables](https://reader036.vdocuments.us/reader036/viewer/2022071709/56649d145503460f949e8a3f/html5/thumbnails/4.jpg)
Example
food = food * 52
Or
food *= 52
![Page 5: Math operators and a challenge Mastery Objectives: Students will— Be able to use augment assignment operators Demonstrate proficiency in using types, variables](https://reader036.vdocuments.us/reader036/viewer/2022071709/56649d145503460f949e8a3f/html5/thumbnails/5.jpg)
Printing Strings and Numbers Together
print “Grand Total: “, total
print “Grand Total: “ + total
![Page 6: Math operators and a challenge Mastery Objectives: Students will— Be able to use augment assignment operators Demonstrate proficiency in using types, variables](https://reader036.vdocuments.us/reader036/viewer/2022071709/56649d145503460f949e8a3f/html5/thumbnails/6.jpg)
Programming Challenges
• Write a program that allows a user to enter his or her two favorite foods. The program should print out the name of a new food by joining the two food names together.
• Write a Tip program where the user enters a restaurant bill total. The program should then display two amounts: a 15-percent tip and a 20-percent tip.
![Page 7: Math operators and a challenge Mastery Objectives: Students will— Be able to use augment assignment operators Demonstrate proficiency in using types, variables](https://reader036.vdocuments.us/reader036/viewer/2022071709/56649d145503460f949e8a3f/html5/thumbnails/7.jpg)
Programming Challenges continued
• Write a Car Salesman program where the user enters the base price of a car. The program should add to the base price tax, license, dealer prep, and destination charge. Make tax and license a percent of the base price. The other fees should be set values. Display the actual price of the car once the extras are applied.
![Page 8: Math operators and a challenge Mastery Objectives: Students will— Be able to use augment assignment operators Demonstrate proficiency in using types, variables](https://reader036.vdocuments.us/reader036/viewer/2022071709/56649d145503460f949e8a3f/html5/thumbnails/8.jpg)
How to turn in Challenges
• Make sure to comment in your name• Print out a copy of the code and the output• Staple both copies together: code first, output
second• Turn in all three challenges as a packet using a
paper clip to clip them all together.