(CIS110 -Cmptr Prgrmmng Dsgn) Week 2 Assignment

(CIS110 -Cmptr Prgrmmng Dsgn) Week 2 Assignment - E xe rci...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: E xe rci se #7 Mil e s­p e r­Gal l on // This program calculates a car’s miles­per­gallon. // Written by Shanna Hawxhurst / / L a s t m o d i f i e d o n 1 / 1 7/ 0 8 // Declare the variables. Declare Real milesDriven Declare Real gallonsUsed Declare Real milesPerGallon / / G et t h e n u m b e r o f m i l e s dr i v e n . D i s p l a y “ E n t e r t h e n u m b e r of m i l e s d r i v e n . ” Input milesDriven / / G et t h e g a l l o n s of g a s u s e d . Display “Enter the gallons of gas used.” Input gallonsUsed // Calculate the miles­per­gallon. Set milesPerGallon = milesDriven * gallonsUsed Display “Your car gets “, milesPerGallon, “miles­per­gallon.” E xe rci se s #8 Ti p , Ta x, a nd To ta l / / T h i s p r o g r a m c a l c u l a t e s t h e t i p a n d t a x f or t h e pr i c e of a m e a l . // Written by Shanna Hawxhurst / / L a s t m o d i f i e d o n 1 / 1 9/ 0 8 // Declare the variables. Declare Real mealPrice Declare Real taxAdded Declare Real tipAdded Declare Real totalCost / / C r e a t e a c o n st a n t f or t h e t i p a n d t h e t a x. Constant Real GRATUITY = .15 Constant Real TAX = 0.07 / / G et t h e p r i c e o f t h e m e a l . Display “Enter the price of the meal.” Input mealPrice Display “Meal Sub­Total : “, mealPrice / / C a l c u l a t e t h e t i p a d d e d t o t h e m e a l pr i c e . Set tipAdded = mealPrice * GRATUITY Display “Tip : “, tipAdded // Calculate the tax added to the meal price. Set taxAdded = mealPrice * TAX Display “Tax : “, taxAdded // Add the tax and tip to the price of the meal. S e t t ot a l C o s t = m e a l P r i c e + t i p A d d e d + t a x A d d e d Display “Total : “, totalCost I li ke d l ea rn in g ab o u t th i s stu ff, so I th o u g h t I wo u ld gi ve i t so me e xtra pra cti ce . Exercise #7 Miles­per­Gallon Flowchart E xercises #8 Tip, Tax, and Total Flowchart ...
View Full Document

This note was uploaded on 01/19/2012 for the course COMPUTER S 100 taught by Professor Brown during the Spring '11 term at Strayer.

Ask a homework question - tutors are online