A simple calculation gives the correct value


PROGRAM 1

A simple calculation gives the correct value of the magnetic field at the center point of a coilpair.
The magnetic flux density, B, at the midpoint between the coils (in tesla) will be given by:

b=(4/5)exp.3/2 μ0nI/r
where:n = the number of turns in each coil
I = the current flowing through the coil wires in amperes
R = radius of the coil loops in meters
μ0 = the vacuum permeability (μ0 = 1.2566370614...×10-6 tesla · meter/ampere ),
which is a well-known physics constant.

Write a program that:
• Defines the vacuum permeability value as a program constant using scientific notation.
• Uses a separate, user-defined function to output a program description header to the user
before prompting for input. This header should contain your name. For example:
• Reads the number of turns in each coil, as input from the user
• Reads the radius of the coil loops (in meters), as input from the user
• Reads the current in the coils (in amperes), as input from the user
• Calculates the magnetic field
o Use the pre-defined pow function from the cmath library to calculate the
fractional value raised to a power, used in the calculations.
• Displays one or two blank lines after reading all the inputs, before displaying the results
• Displays all data using the format given in the following sample output, which meet the
following specifications:
 The number of turns in the coils should be displayed first.
 The coil radius and current should be displayed in fixed format, carried out to 3
decimal places. Their decimals should line up.
 The vacuum permeability constant and calculated magnetic field should be
displayed in scientific format, carried out to 5 decimal places. Their decimals
should line up.
 All unit values should line up.
NOTE: You are not required to validate any of the user input. You may assume that the user will
enter a valid answer for each question.
Additionally, the program must:
• Compile without errors,
• Include appropriate mnemonic constant and variable declarations,
• Prompt the user for data in a meaningful way,
• Pause the program after the data is displayed,


PROGRAM 2
If you know the base length (b) and height (h) of a square pyramid, then you can calculate the
slant height (s), surface area (A), and volume (V) of the pyramid using the following formulas.
Volume: V = 1/3 bexp.2 h
Slant Height: couldnt copy it but its on google.
surface area: couldnt copy ut but its on google
Note that the slant height is the hypotenuse of the right triangle, whose other two sides are the
height and half the base of the pyramid.
Again, don't let the equations intimidate you. These formulas simply perform addition,
multiplication, division, squaring, and finding a square root.
Requirements:
Write a program that will:
• Display a program description to the user before asking for any input
• Read the base length and height of a right pyramid as input from the user
• Display all of the inputs back to the user, formatted to 2 decimal place as shown in the
sample. The decimals of the two values should line up.
• Calculate the volume of the right pyramid using the above formula
o Notice that the square of the base is used in all three formulas. Compute and store
this value separately. Then use the stored value in all the formulas.

• Calculate the slant height of the right pyramid using the above formula
• Calculate the surface area of the right pyramid using the above formula
o Use the pre-defined sqrt function from the cmath library in both the slant height
and surface area calculations.
• Write and call a separate, user-defined function to output the calculation results:
o The function should have thee input parameters: surface area, slant height, and
volume
o From within the user-defined function, display surface area, slant height, and
volume of the right pyramid formatted as shown below, each rounded to 2
decimal places. The decimals of the three values should line up, and also line up
with the input values displayed from main.
o No calculations should be performed from within this function.

PROGRAM 3
The local discount carpet store would like help calculating customer bills for carpet.
Carpet costs include the cost of the carpet and the pad. A customer may also choose to have
furniture moved out of and back into the space and to have the old carpet removed and hauled
away when the new carpet is installed.
Write a program to help compute the bill for one customer.
Specifications:
• Carpet and pad costs are based upon the number of square feet of carpet needed. Rooms
are measured in inches. There are 12 inches to a foot, and 3 feet in a yard, and 9 square
feet in 1 square yard.
• All carpet in the store runs $25.94 per square yard.
• Two pad types are available:
o The standard pad costs $5.25 per square yard.
o The premium pad costs $6.73 per square yard.
• By default, when the customer has new carpet installed, the old carpet will be removed
and hauled away. If a customer chooses to do this part himself, they will be given a 6.5%
discount on the cost of the carpet only.
• If the customer wants the furniture moved, there is a $26.66 charge per room.
Implementation Requirements:
Data Storage:
• The program must use constants for ALL fixed values (therefore, there should be no
hardcoded numbers in your program).
• The program shall use descriptive names for all constants and variables, and follow the
naming conventions in the Coding Standards.
• The program shall use double type constants and variables for all floating point values
(not float).
©2013, Regis University
The user will enter the following input:
• The length and width of the space
• The type of pad to install
o Read the pad type as a single character ( 's'/'S' for standard or 'p'/'P' for premium).
The user may enter the character in either upper or lowercase. Use a pre-defined
function from the cctype library to insure that the character is stored in uppercase
when your code uses the value later to decide what to charge and what to display.
• Whether the customer wants to the carpet store to remove the old carpet
o Read from the user ('s'/'S' for store removal, 'c'/'C' for customer removal) and store
as a single character
o After reading the input character, the program will assign a value to a Boolean
variable called giveDiscount (true for customers who remove their own carpet,
false for customers who will have the store remove the carpet) and use only that
Boolean in later processing, when testing the value to decide whether to give a
discount.
o The user may enter the character in either upper or lowercase. The program must
use a logical operator to test for both upper and lowercase when deciding whether
to store true or false in the Boolean variable (i.e. Use a logical operator instead
of using a cctype predefined function).
• Whether the customer wants the furniture moved
o Read answer from the user as a string: "yes" or "no"
o The prompt should indicate that the string must be entered in all lowercase letters.
o If the user enters "yes", also prompt for the number of rooms, and calculate the
total furniture moving charge.
NOTE: No error checking of the user input is required. You may assume that the user
entered a valid answer for each question, and assume also valid input for test cases.
Required User-Defined Function:
• Create separate a user-defined function to calculate the number of square yards.
• The function will take two input parameters: the length and width of the space.
• The function will return the number of SQUARE yards of carpet needed for the space.

PROGRAM 4
The IRS may allow a deduction for Student Loan Interest paid. A taxpayer can claim the
deduction if his/her income falls below specified limits and the filing status is any filing status
except married filing separately. This deduction may decrease the amount of income subject to
tax by up to $2,500.
You will write a program that carries out the logic of the IRS worksheet to determine how much
interest may be deducted.
Sample IRS instructions for each line of the worksheet (modified slightly from actual worksheet)
This worksheet may be used by any taxpayer who is not married filing separately.
Line 1 Enter the total interest paid for the year on qualified student loans on line 1.
(worksheet amount will be limited to a maximum of $2500, even if a large amount
was paid)
Line 2 Enter Total Income amount from Form 1040, line 22 on line 2.
Line 3 Enter Adjustments to Income from Form 1040, lines 23 through 32 on line 3.
Line 4 Subtract line 3 from line 2 and enter the result on line 4.
Line 5 Determine the Income Limit amount for your filing status from the list below and
enter it on line 5:
Single, Head of household, Qualifying Widow(er) - $ 60,000
Married filing jointly - $ 120,000
Line 6 Is the amount on line 4 more than the amount on line 5?
No. Skip lines 6 through 8. Enter the amount from line 1 on line 9.
Yes. Subtract line 5 from line 4 and enter the Amount Over on line 6.
Line 7 Divide line 6 by $15,000 (or $30,000 if married filing jointly) to determine a
percentage that will be excluded from the deduction.
Enter the result rounded to three places on line 7.
If the result is 1.000 or more, enter 1.000 on line 7.
Line 8 Multiply line 1 by line 7 and enter the result on line 8.
Line 9 Subtract line 8 by line 1 and enter result on line 9.
The line 9 amount is your Student Loan Interest Deduction.
Enter the line 9 results on Form 1040, line 33.
(see next page for more details)
©2013, Regis University
The user inputs will be:
• Filing status (one of the following)
1. Single,
2. Married, Filing Jointly,
3.Head of Household,
4. Qualifying Widow,
5. Married, Filing Separately.
• Amount of Interest paid on Student Loans
• Total Income (1040, line 22)
• Total Adjustments (1040, lines 23 - 32)

PROGRAM 5
A university would like you to write a program to compute the fees charged on a student tuition
bill. You will also write a test plan for this program.
Tuition is the same for all students, and is charged based on the number of credit hours enrolled
in. The cost per credit hour is $465.
The school calculates student fees as a percentage of the total tuition being charged, unless the
student is a non-degree seeking student.
The following rates will be used to compute the student fees:
Credit
Hours
Non-degree
seeking fee
(flat fee)
Undergraduate
Rates
(% of tuition)
Graduate
Rates
(% of tuition)
1 - 3
$ 100
3%
4 - 9 2.8% 2.7%
10 - 14 2.5% 2.4%
15 - 18 2.2% 2.1%
over 18 1.9%
NOTES:
1. All of the fixed values in the table should be stored as constants, using descriptive
constant names. This means that you will need to create constants for the tuition cost, credit
hour limits of each bracket, and the rates in each bracket.
2. The school should be able to modify any of the figures, simply by changing the constant
values, and without having to modify any of the executable code.
3. Do not embed any constant values in the constant names!
Example:
const double RATE_OVER_18 = 0.019; // incorrect
This constant is defined incorrectly, because the credit hour limit of 18 is embedded in
the constant name.
const int RATE4_HOUR_LIMIT = 18;
const double RATE5 = 0.019; // better!
In addition to the main function, you also will write a separate user-defined function that will
use the chart above to determine the student fee percentage rate, based on student type and credit
hours.
The user-defined function will:
 Be given a descriptive name that describes what the function does
 Take student type and number of credit hours as input arguments and will return a fee
rate for use in the student fee calculations in the main function.
 Use BOTH nested if statement(s) AND extended multi-way selection if statement(s) to
determine the correct fee rate for the student.
NOTE: No switch statements shall be used in this program.
Program Implementation
The program should first describe its purpose.
Then prompt for and read the student type from the user.
NOTE: The program should work no matter whether the user enters the student type
in either upper or lowercase.
If the student is an undergraduate or graduate student, the program should then prompt for and
read in the number of credit hours the student is enrolled in.

PROGRAM 6
A partial electronic color code chart, used to indicate the ratings of electronic components, is
shown below.
You will write a program to identify the digit represented by a specific color code.

COLOR DIGIT 

BLACK 0
BROWN 1
RED 2
ORANGE 3
YELLOW 4
GREEN 5
BLUE 6
VIOLET 7
GRAY 8
WHITE 9 
You will write a program to identify the digit represented by a specific color code.
The program should first describe its purpose.
Then prompt the user for one letter (character) to identify the color.
Use one large nested switch statement to output one of the following messages:
• If the letter is 'R' or 'r', output: Red stands for digit 2.
• If the letter is 'O' or 'o', output: Orange stands for digit 3.
• If the letter is 'Y' or 'y', output: Yellow stands for digit 4.
• If the letter is 'V' or 'v', output: Violet stands for digit 7.
• If the letter is 'W' or 'w', output: White stands for digit 9.
• If the letter is 'B' or 'b', prompt for the user for a second letter.
o If the second letter is 'R' or 'r', output: Brown stands for digit 1.
o If the second letter is 'L' or 'l', prompt for the third letter:
 If the third letter is 'A' or 'a', then output: Black stands for digit 0.
 If the third letter is 'U', or 'u', then output: Blue stands for digit 6.
• If the letter is 'G' or 'g', prompt for the next two letters at once (note that you can still
read them into two separate character variables). Be sure to verify the correctness of
BOTH the second and third letters (not just the third letter!)
o If the second letter is 'R' or 'r'
 and the third letter is 'A' or 'a', output: Gray stands for digit 8.
 and the third letter is 'E' or 'e', output: Green stands for digit 5.
• If none of the above situations apply, output: Unknown Color
The program should always produce an output message. Therefore, you need to insure that ALL
possible input combinations produce output of either a correct color and digit, or the "Unknown
Color" message.
NOTES:
The program should not require the user to enter any more letters than are necessary to
determine the output.
You are not allowed to use any if statements in this program.
There will be no functions in this program, except for main.
General Notes for BOTH programs:
1) Program logic must be indented correctly.
2) Comments must be included for any constant/variable whose name is not completely
descriptive.
3) Include top of program comments as specified in course Content section 1.8
4) Provide a comment above each user-defined function that includes:
What the function does
The name and a description of the parameters that are input to the function
A name (if available) and a description of what is returned from the function

Request for Solution File

Ask an Expert for Answer!!
Programming Languages: A simple calculation gives the correct value
Reference No:- TGS086276

Expected delivery within 24 Hours