8 Logical Funclions and Selection Structures Problems 309 30 8.13 Suppose the following matrix represents the number of saws ordered from your company cach month over the last year. (b) Write a program that prompts the user to enter one of the following: triangle saws = (1,4,5,3,7,5,3,10,12,8, 7, 4] square pentagon hexagon Use the input to define the value of n via a switch/case structure; then use n to calculate the sum of the interior angles in the figure. All the numbers should be zero or positive. (a) Use an if statement to check whether any of the values in the matrix are invalid. (Evaluate the whole matrix at once in a single if state- ment.) Send the message "All valid" or else “Invalid number ſound" to the screen, depending on the results of your analysis. (b) Change the saws matrix to include at least one negative number, and check your program to make sure that it works for both cases. 8.14 Most large companies encourage employees to save by matching their con- tributions to a 401 (k) plan. The government limits how much you can save in these plans, because they shelter income from taxes until the money is withdrawn during your retirement. The amount you can save is tied to your income, as is the amount your employer can contribute. The government will allow you to save additional amounts without the tax benefit. These plans change from year to year, so this example is just a made-up "what if." Suppose the Quality Widget Company has the savings plan described in Table 8.10. Create a function that finds the total yearly contribution to your savings plan, based on your salary and the percentage you contribute. Remember, the total contribution consists of the employee contribution and the company contribution. (c) Reformulate your program from part (b) so that it uses a menu. 8.16 At a local university, each engineering major requires a different number of credits for graduation. For example, recently the requirements were as follows: Civil Engineering Chemical Engineering Computer Engineering Electrical Engineering Mechanical Engineering 130 130 122 126.5 129 Prompt the user to select an engineering program from a menu. Use a switch/case structure to send the minimum number of credits required for graduation back to the command window. 8.17 The easiest way to draw a star in MATLAB® is to use polar coordinates. You simply need to identify points on the circumference of a circle and draw lines between those points. For example, to draw a five-pointed star, start at the top of the circle (0 = 7/2, r 1) and work counterclockwise (Figure P8.17). Prompt the user to specify either a five-pointed or a six-pointed star, using a menu. Then create the star in a MATLAB® figure window. Note that a six-pointed star is made of three triangles and requires a strategy diſferent from that used to create a five-pointed star. Table 8.10 Quality Widget Company Savings Plan Maximum You Can Save Tax Free Maximum the Company Will Match Income Up to $30,000 10% 10% Between $30,000 and 10% $60,000 10% of the first $30,000 and 5% of the amount above $30,000 Switch, ifclsc Between $60,000 and 10% of the first $60,000 and 8% $100,000 10% of the first $30,000 and 5% of the amount between $30,000 and $60,000; nothing for the remainder above $60,000 CHALLENGE PROBLEMS of the amount above $60,000 8.18 Most major airports have separate lots for long-term and short-term parking. The cost to park depends on the lot you select, and how long you stay. Consider this rate structure from the Salt Lake International Airport during 10% of the first $60,000 and 8% of the amount between $60,000 and $100,000; nothing on the amount above $100,000 Nothing-highly compensaled employees are exempt from this plan and participate in stock options instead Above $100,000 the summer of 2008. • Long-Term (Economy) Parking • The first hour is $1.00, and each additional hour or fraction thereof is $1.00 Daily maximum $6.00 • Weekly maximum $42.00 • Short-Term Parking • The first 30 minutes are free and each additional 20 minutes or fraction thereof is $1.00 • Daily maximum $25.00 SWITCH/CASE 8.15 In order to have a closed geometric figure composed of straight lines (Figure P8.15), the angles in the figure must add to (n – 2) (180 degrees) where n is the number of sides. Write a program that asks the user the following: Figure P8.15 Regular Polygons. (a) Prove this statement to yourself by creating a vector called n from 3 to 6 and calculating the angle sum from the formula. Compare what you know about geometry with your answer. • Which lot are you using? • How many wecks, hours, days, and minutes did you park? Your should then calculate the parking bill. program

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

QUESTION 8.14: User input of salary and response that is a calculation for the user maximum contribution and the company maximum contribution based on the if, else tests for salary.  Submit the command window showing the test for a range of salaries.  Make sure you show a test for each scenerio. 

8 Logical Funclions and Selection Structures
Problems 309
30
8.13 Suppose the following matrix represents the number of saws ordered from
your company cach month over the last year.
(b) Write a program that prompts the user to enter one of the following:
triangle
saws = (1,4,5,3,7,5,3,10,12,8, 7, 4]
square
pentagon
hexagon
Use the input to define the value of n via a switch/case structure;
then use n to calculate the sum of the interior angles in the figure.
All the numbers should be zero or positive.
(a) Use an if statement to check whether any of the values in the matrix
are invalid. (Evaluate the whole matrix at once in a single if state-
ment.) Send the message "All valid" or else “Invalid number ſound" to
the screen, depending on the results of your analysis.
(b) Change the saws matrix to include at least one negative number, and
check your program to make sure that it works for both cases.
8.14 Most large companies encourage employees to save by matching their con-
tributions to a 401 (k) plan. The government limits how much you can save
in these plans, because they shelter income from taxes until the money is
withdrawn during your retirement. The amount you can save is tied to your
income, as is the amount your employer can contribute. The government
will allow you to save additional amounts without the tax benefit. These
plans change from year to year, so this example is just a made-up "what if."
Suppose the Quality Widget Company has the savings plan described in
Table 8.10. Create a function that finds the total yearly contribution to your
savings plan, based on your salary and the percentage you contribute.
Remember, the total contribution consists of the employee contribution
and the company contribution.
(c) Reformulate your program from part (b) so that it uses a menu.
8.16 At a local university, each engineering major requires a different number
of credits for graduation. For example, recently the requirements were as
follows:
Civil Engineering
Chemical Engineering
Computer Engineering
Electrical Engineering
Mechanical Engineering
130
130
122
126.5
129
Prompt the user to select an engineering program from a menu. Use a
switch/case structure to send the minimum number of credits required
for graduation back to the command window.
8.17 The easiest way to draw a star in MATLAB® is to use polar coordinates. You
simply need to identify points on the circumference of a circle and draw lines
between those points. For example, to draw a five-pointed star, start at the top
of the circle (0 = 7/2, r 1) and work counterclockwise (Figure P8.17).
Prompt the user to specify either a five-pointed or a six-pointed star,
using a menu. Then create the star in a MATLAB® figure window. Note that
a six-pointed star is made of three triangles and requires a strategy diſferent
from that used to create a five-pointed star.
Table 8.10 Quality Widget Company Savings Plan
Maximum You Can
Save Tax Free
Maximum the Company
Will Match
Income
Up to $30,000
10%
10%
Between $30,000 and 10%
$60,000
10% of the first $30,000 and 5%
of the amount above $30,000
Switch, ifclsc
Between $60,000 and 10% of the first $60,000 and 8%
$100,000
10% of the first $30,000 and 5%
of the amount between $30,000
and $60,000; nothing for the
remainder above $60,000
CHALLENGE PROBLEMS
of the amount above $60,000
8.18 Most major airports have separate lots for long-term and short-term parking.
The cost to park depends on the lot you select, and how long you stay.
Consider this rate structure from the Salt Lake International Airport during
10% of the first $60,000 and 8%
of the amount between $60,000
and $100,000; nothing on the
amount above $100,000
Nothing-highly compensaled
employees are exempt from this
plan and participate in stock
options instead
Above $100,000
the summer of 2008.
• Long-Term (Economy) Parking
• The first hour is $1.00, and each additional hour or fraction thereof is
$1.00
Daily maximum $6.00
• Weekly maximum $42.00
• Short-Term Parking
• The first 30 minutes are free and each additional 20 minutes or fraction
thereof is $1.00
• Daily maximum $25.00
SWITCH/CASE
8.15 In order to have a closed geometric figure composed of straight lines
(Figure P8.15), the angles in the figure must add to
(n – 2) (180 degrees)
where n is the number of sides.
Write a program that asks the user the following:
Figure P8.15
Regular Polygons.
(a) Prove this statement to yourself by creating a vector called n from 3 to 6
and calculating the angle sum from the formula. Compare what you
know about geometry with your answer.
• Which lot are you using?
• How many wecks, hours, days, and minutes did you park? Your
should then calculate the parking bill.
program
Transcribed Image Text:8 Logical Funclions and Selection Structures Problems 309 30 8.13 Suppose the following matrix represents the number of saws ordered from your company cach month over the last year. (b) Write a program that prompts the user to enter one of the following: triangle saws = (1,4,5,3,7,5,3,10,12,8, 7, 4] square pentagon hexagon Use the input to define the value of n via a switch/case structure; then use n to calculate the sum of the interior angles in the figure. All the numbers should be zero or positive. (a) Use an if statement to check whether any of the values in the matrix are invalid. (Evaluate the whole matrix at once in a single if state- ment.) Send the message "All valid" or else “Invalid number ſound" to the screen, depending on the results of your analysis. (b) Change the saws matrix to include at least one negative number, and check your program to make sure that it works for both cases. 8.14 Most large companies encourage employees to save by matching their con- tributions to a 401 (k) plan. The government limits how much you can save in these plans, because they shelter income from taxes until the money is withdrawn during your retirement. The amount you can save is tied to your income, as is the amount your employer can contribute. The government will allow you to save additional amounts without the tax benefit. These plans change from year to year, so this example is just a made-up "what if." Suppose the Quality Widget Company has the savings plan described in Table 8.10. Create a function that finds the total yearly contribution to your savings plan, based on your salary and the percentage you contribute. Remember, the total contribution consists of the employee contribution and the company contribution. (c) Reformulate your program from part (b) so that it uses a menu. 8.16 At a local university, each engineering major requires a different number of credits for graduation. For example, recently the requirements were as follows: Civil Engineering Chemical Engineering Computer Engineering Electrical Engineering Mechanical Engineering 130 130 122 126.5 129 Prompt the user to select an engineering program from a menu. Use a switch/case structure to send the minimum number of credits required for graduation back to the command window. 8.17 The easiest way to draw a star in MATLAB® is to use polar coordinates. You simply need to identify points on the circumference of a circle and draw lines between those points. For example, to draw a five-pointed star, start at the top of the circle (0 = 7/2, r 1) and work counterclockwise (Figure P8.17). Prompt the user to specify either a five-pointed or a six-pointed star, using a menu. Then create the star in a MATLAB® figure window. Note that a six-pointed star is made of three triangles and requires a strategy diſferent from that used to create a five-pointed star. Table 8.10 Quality Widget Company Savings Plan Maximum You Can Save Tax Free Maximum the Company Will Match Income Up to $30,000 10% 10% Between $30,000 and 10% $60,000 10% of the first $30,000 and 5% of the amount above $30,000 Switch, ifclsc Between $60,000 and 10% of the first $60,000 and 8% $100,000 10% of the first $30,000 and 5% of the amount between $30,000 and $60,000; nothing for the remainder above $60,000 CHALLENGE PROBLEMS of the amount above $60,000 8.18 Most major airports have separate lots for long-term and short-term parking. The cost to park depends on the lot you select, and how long you stay. Consider this rate structure from the Salt Lake International Airport during 10% of the first $60,000 and 8% of the amount between $60,000 and $100,000; nothing on the amount above $100,000 Nothing-highly compensaled employees are exempt from this plan and participate in stock options instead Above $100,000 the summer of 2008. • Long-Term (Economy) Parking • The first hour is $1.00, and each additional hour or fraction thereof is $1.00 Daily maximum $6.00 • Weekly maximum $42.00 • Short-Term Parking • The first 30 minutes are free and each additional 20 minutes or fraction thereof is $1.00 • Daily maximum $25.00 SWITCH/CASE 8.15 In order to have a closed geometric figure composed of straight lines (Figure P8.15), the angles in the figure must add to (n – 2) (180 degrees) where n is the number of sides. Write a program that asks the user the following: Figure P8.15 Regular Polygons. (a) Prove this statement to yourself by creating a vector called n from 3 to 6 and calculating the angle sum from the formula. Compare what you know about geometry with your answer. • Which lot are you using? • How many wecks, hours, days, and minutes did you park? Your should then calculate the parking bill. program
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Similar questions
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY