Ask Programming Language Expert

The topic of this assignment was chosen so that you won't allow mathematical equations and scientific notation to intimidate you. No knowledge is required to complete the assignment beyond knowing how to perform mathematical operations within a formula.

NOTE: Use the double precision data type for all floating point variables in these programs (instead of the single precision float data type).

Program #1

Electro-magnetic force describes the influence that one electrical charge has on another when neither charge is moving.

The equation for this electro-magnetic force in Newtons is: , where the constant and where: π is the constant Pi, whose value to 10 decimal places is 3.1415926535

E0 is a constant known as the permittivity of free space with value = 8.854 x 10-12 coulombs2 per Newton meters2 q1 and q2 represent the charges of two objects in coulombs r represents the distance between the centers of the objects in meters K is Coulomb's constant, in Newton meters2 Coulombs-2

For the Curious: Electrical charges can either attract or repel each other, as q1 and q2 may be either positive or negative. When the have same signs, they repel each other. When they have opposite signs, they attract each other.

Program Requirements: Write a program to compute the electro-magnetic force between 2 charged objects. The program shall: ? Define a constant, using scientific notation, for the permittivity of free space. ? Define another constant, using fixed notation, for Pi carried out to 10 decimal places.

Use a separate, user-defined function to output the program description header to the user before prompting for input. This header should contain your name. For example:

Read user input 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.

o Read the charges of two objects, as input from the user. o Read the distance between the centers of the two objects, as input from the user.

Calculate the electro-magnetic force between the objects. Display several 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 charges of both objects, and the distance between the objects, are displayed first, in fixed format, carried out to 3 decimal places. Their decimals should all line up.

The permittivity of free space, the calculated Coulomb's constant, and the calculated electro-magnetic force are 1ll displayed in scientific format, carried out to 4 decimal places. Their decimals should line up.

All unit descriptions also line up.

Additionally, the program must: Compile without errors, Include appropriate mnemonic constant and variable declarations, Prompt the user for data in a meaningful way, Adhere to the documentation standards for this course (see course Content section 1.8)

(see sample input/output on next page)

Calculation of Electro-magnetic Force between two Objects By Mr. YOUR NAME

Sample Input and Output:

Notes: This output example provides convenient test data that can be used to verify the calculations in your program.

The representation of the following number uses scientific notation: o 8.854 x 10-12 is the same as 0.000000000008854, and is represented in C++ scientific notation as 8.854E-12. o The minus sign in 8.854E-12 indicates a negative exponent (i.e. a fraction). o By default, the exponent in scientific notation is displayed using 3 digits, like this: 8.854E-012. o The number of digits in the scientific notation can be changed via the setprecision output manipulator (i.e. the same method as fixed notation). ? Users can also input values at the keyboard using scientific notation

(see next page for program 2 requirements)

Calculation of Electro-magnetic Force between two Charged Objects By Mr. YOUR NAME

Enter charge of object 1 (in coulombs): 1.1 Enter charge of object 2 (in coulombs): 2.2

Enter distance between the centers of the two objects (in meters): 10

RESULTS:

Charge of first object: 1.100 coulombs Charge of second object: 2.200 coulombs Distance between objects 10.000 meters
Permittivity of Free Space: 8.8540e-012 coulombs^2 per Newton meters^2 Coulomb's Constant: 8.9877e+009 Newton meters^2 Coulombs^-2

Electromagnetic Force: 2.1750e+008 Newtons

Program #2

A right circular cone has a circular base, and the line from the center of the base to the tip of the cone forms a right angle with the base.

If you know the height (h) of a cone and the radius (r) of the base of the cone, then you can calculate the slant height (s), surface area (a), and volume (v) of the cone using the following formulas.

Slant Height: s = √ Surface Area: A =

Volume: v =

Note that the slant height is the hypotenuse of the right triangle, whose other two sides are the height and the radius of the base.
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. Defines a constant for PI, using fixed notation, carried out to 5 decimal places (value for Pi was given in program 1). Read the radius of the base of a right circular cone, as input from the user. Read the height of a right circular cone, as input from the user. Calculate the square of the radius, and store its value in a variable. (This value is used in all of the formulas. Use the stored value in all the formulas.) o Use the pre-defined pow function from the cmath library for squaring. Calculate the slant height of the right circular cone, using the above formula. o Use the pre-defined sqrt function from the cmath library to implement this calculation. Calculate the surface area of the right circular cone, using the above formula. Calculate the volume of the right circular cone, using the above formula. From the main function, display a few blank lines, and then a RESULTS header. From the main function, display the base radius and height of the right circular cone, rounded to 2 decimal places as shown in the sample output. The decimals of both values should line up. Write and call a separate, user-defined function to output the calculation results: o The function should have thee input parameters: slant height, surface area, and volume o From within the user-defined function, display surface area, slant height, and volume of the right circular cone 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.

Sample Input and Output

Documentation

1) Comment any constants/variables whose names are not completely descriptive.

Program for Right Circular Cone calculations

Enter cone radius (in inches): 5.5 Enter cone height (in inches): 10

RESULTS: For a Right Circular Cone with Radius of 5.50 inches Height of 10.00 inches Cone Slant Height is 11.41 inches Cone Surface Area is 292.23 square inches Cone Volume is 316.78 cubic inches

2) Be sure to include top of program comments as specified in course Content section 1.8: Your name, the course, and the assignment number What the Program Does including: What is Input Processing Performed What is Output

3) You must also include a comment above each user-defined function that includes: What the function does The name and a description of any parameters that are input to the function

4)For readability, make sure you have: - a SPACE before and after each operator (+, -, *, /, =) - a SPACE after each comma in your code - blank lines between sections of your code

5) Remember that dividing one integer by another integer will produce an integer result. Example: 1 / 3 = 0 So if you want floating point results, be sure that one of the operands is a floating point value. Example: 1 / 3.0 = 0.3333...

Submission

This programming assignment is due by midnight Monday. Submit your program source code (both of the .cpp files) to the Prog Assn 2 dropbox (located under the Dropbox tab in the online course). Both files should be attached to one submission for programming assignment 2.

Before submitting your program files, you MUST name them as follows: Lastname-wk2-prog1.cpp Lastname-wk2-prog2.cpp

For example: Smith-wk2-prog1.cpp Smith-wk2-prog2.cpp

Programming Language, Programming

  • Category:- Programming Language
  • Reference No.:- M91330104
  • Price:- $45

Guranteed 36 Hours Delivery, In Price:- $45

Have any Question?


Related Questions in Programming Language

Assignment - haskell program for regular expression

Assignment - Haskell Program for Regular Expression Matching Your assignment is to modify the slowgrep.hs Haskell program presented in class and the online notes, according to the instructions below. You may carry out th ...

Assignment task -q1 a the fibonacci numbers are the numbers

Assignment Task - Q1. (a) The Fibonacci numbers are the numbers in the following integer sequence, called the Fibonacci sequence, and are characterised by the fact that every number after the first two is the sum of the ...

Question - create a microsoft word macro using vba visual

Question - Create a Microsoft Word macro using VBA (Visual Basic for Applications). Name the macro "highlight." The macro should highlight every third line of text in a document. (Imagine creating highlighting that will ...

Assignmentquestion onegiving the following code snippet

Assignment Question One Giving the following code snippet. What kind of errors you will get and how can you correct it. A. public class HelloJava { public static void main(String args[]) { int x=10; int y=2; System.out.p ...

Assignment - proposal literature review research method1

Assignment - Proposal, Literature Review, Research Method 1. Abstract - Summary of the knowledge gap: problems of the existing research - Aim of the research, summary of what this project is to achieve - Summary of the a ...

1 write a function named check that has three parameters

1. Write a function named check () that has three parameters. The first parameter should accept an integer number, andthe second and third parameters should accept a double-precision number. The function body should just ...

Assignment - horse race meetingthe assignment will assess

Assignment - Horse Race Meeting The Assignment will assess competencies for ICTPRG524 Develop high level object-oriented class specifications. Summary The assignment is to design the classes that are necessary for the ad ...

Task silly name testeroverviewcontrol flow allows us to

Task: Silly Name Tester Overview Control flow allows us to alter the order in which our programs execute. Building on our knowledge of variables, we can now use control flow to create programs that perform more than just ...

Structs and enumsoverviewin this task you will create a

Structs and Enums Overview In this task you will create a knight database to help Camelot keep track of all of their knights. Instructions Lets get started. 1. What the topic 5 videos, these will guide you through buildi ...

Task working with arraysoverviewin this task you will

Task: Working with Arrays Overview In this task you will create a simple program which will create and work with an array of strings. This array will then be populated with values, printed out to the console, and then, w ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As