Premium Essay

Psudocode

In:

Submitted By banglarsporsho
Words 379
Pages 2
Unit 6 Programing Exercise
#5. COLOR MIXER
''' The colors red, blue, and yellow are known as the primary colors because they cannot be made by mixingmother colors. When you mix two primary colors, you get a secondary color. Design a program that prompts the user to enter the names of two primary colors to mix. If the user enters anything other than red, blue, or yellow, the program should display an error message. Otherwise, the program should display the name of the secondary color that results.'''

def main(): color1=input("Please enter a primary color (red, blue, or yellow): ") color2=input("Please enter a different primary color to mix with the first: ") print(color_mixer(color1,color2)) def color_mixer(a,b): if a or b == "red" and a or b == "blue" and a != b: return("purple") else: if a or b == "red" and a or b == "yellow" and a != b: return("orange") else: if a or b == "blue" and a or b == "yellow" and a != b: return("purple") else: return("Error: Please enter two different primary colors.") main()
8. Change for a Dollar Game
Design a change-counting game that gets the user to enter the number of coins required to make exactly one dollar. The program should ask the user to enter the number of pennies, nickels, dimes, and quarters. If the total value of the coins entered is equal to one dollar, the program should congratulate the user for winning the game. Otherwise, the program should display a message indicating whether the amount entered was more than or less than one dollar. def change_to_cents(pennies, nickels, dimes, quarters): cents = pennies cents += nickels*5 cents += dimes*10 cents += quarters*25 return cents

def display_change(pennies, nickels, dimes, quarters): print

Similar Documents

Premium Essay

Psudocode

...Final Project Plan Instructions Your final project will be to analyze, design, and document a simple program that utilizes a good design process and incorporates sequential, selection and repetitive programming statements as well as at least one function call and the use of at least one array. The specific problem you need to solve for the final project is: Design a program that will allow a user to Input a list of your family members along with their age and state where they reside. Determine and print the average age of your family and print the names of anyone who live in Texas. Final Project Deliverables: There are two deliveries for this project. The first delivery is the project plan which provides your problem statements, problem analysis, and how it will comply with the project specifications. The project plan is worth 10% of your grade. The final delivery will be your completed project design along with your code comments and comprehensive test plan. The final delivery is worth 20% of your grade. Your project plan is due in week 7 by midnight EST, on the specific date posted in the class schedule. The final delivery is due no later than the last day of class. Your instructor’s policy on late projects applies to this project. Example Project Plan and Final Project template files, containing the required sections are included in the available resources. You should use this document to start your writing and fill in all of the details required. Project...

Words: 310 - Pages: 2

Free Essay

Psudocode for for Program 4

...Pseudocode for Java Assignment/program #4 Version 1.0 import java.util.ArrayList import java.util.Scanner main() { Declare one dimensional array named Array1[]as double Declare a variable to hold the Name as String Declare/initialize base salary to 25,000 (from Program #3) Declare/initialize target sales to 120,000 (from Program #3) Declare annual sales variable as double Declare Total compensation as double create employee annual sales input via Scanner Input Name of salesperson - Name = keyboard.next() Print salesperson’s name and salary (25,000) Input annual sales from the user through the keyboard Input annual Sales amount from user if annual sales < 120000 { Print annual compensation is 25,000 } else if(annual sales > 120000 and annual sales < 150000 (from table in Program #3) } incentives = (annual sales * 0.10) Total compensation = salary + incentives Print the total compensation { else if (annual sales > 150000) { AccIncentives = (annual sales – 150000) * 1.25 Incentives = (Annual Sales + AccIncentives) * 0.10 Total Compensation = salary + incentives } Input second person’s salesperson’s name Input second sales person’s annual salary If (Total compensation > second sales person’s annual salary) { Print “you made...

Words: 272 - Pages: 2

Premium Essay

Unit 3

...and the w = 5, x = 4, y = 8, z = 2. What value will be stored in result in each of the following statement? A. x+y=4+5 B. z*2=2*2 C. y/x=8/4 D. y-z=8-2 5. Write a pseudocode statement that declares the variable cost so it can hold real number. • Floating-point variable cost 6. Write a pseudocode statement that declares the variable total so it can hold integer. Initialize the variable with the value 0. • Declare Real price = 99.95 • Display “the original price.’ • Input item original price • Display “price” 7. Write a pseudocode statement that assigns the value 27 to the variable count. • Count:=27 8. Write a pseudocode statement that assigns the sum of 10 and 14 to the variable total. • Set total = 10+14 9. Write a psudocode statement that subtracts the variable downPayment from the variable total and assign the results for the variable due. • Set due = total – downPayment 10. Write a psuedocode statement that multiplies the variable subtotal by .15 and assign the result to the variable totalFee. • Declare Int subtotal • Declare Int totalFee • Declare Int taxTotal = .15 • Set totalFee = subtotal * taxTotal Programming Exercise //Declare variables • String itemName • Real subtotal • Real saleTax • Real countryTax • Real saleTax • Real countryTax • Real...

Words: 375 - Pages: 2

Free Essay

Home Maintenance Program

...Home Maintenance Program Nicole Chambers Andy Labance Pharia Reed 8/26/2014 PRG/221 James Johnson Have you ever finished cleaning your house, sat down to relax and then suddenly remember ‘I forgot to mop the floors’? Using this program will ensure that missing a step while cleaning your home is a thing of the past. We are going to use cleaning the kitchen as our example, and the way this program works is it will tell you in a sensible order to complete all of the required cleaning tasks to clean your kitchen properly, so that you’re not i.e. cleaning the floors then wiping counters and messing up the floors again. ABOUT THE PROGRAM: The first step this program tells you to do would be to wash the dishes, the program will prompt you to answer whether or not you have washed all of the dishes, if you answer no the program will tell you that you must wash the dishes in order to proceed to the next task and then prompt you to answer if you have washed the dishes. The program will continuously repeat this process until you answer ‘yes’ all of the dishes have been washed. After you answer ‘yes’ all of the dishes have been washed the program will tell you to proceed on to the next task of wiping down and sanitizing the counter tops. If in the beginning (the first time you are prompted to answer if the dished have been cleaned) you answer ‘yes’ all of the dishes have been washed this program will the direct you to proceed to completing the next task of...

Words: 782 - Pages: 4