...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...
Words: 379 - Pages: 2
...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
...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
...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