1 answer

Write a program that calculates voltage from current and resistance values. Create three one-dimensional arrays named...

Question:

Write a program that calculates voltage from current and resistance values.

Create three one-dimensional arrays named current, resistance and voltage, each capable of holding 10 double-precision values. The values stored in current and resistance are as follows:
current = 10.62, 14.89, 13.21, 16.55, 18.62, 9.47, 6.58, 18.32, 12.15, 3.98
resistance = 4.0, 8.5, 6.0, 7.35, 9.0, 15.3, 3.0, 5.4, 2.9, 4.8

Have your program pass these three arrays to a function called calcVolts() which calculates the elements in the voltage array as the product of the equivalent elements in the current and resistance arrays, for example:
voltage[1] = current[1] * resistance[1]

Write the calcVolts() function (prototype, header, body) using pointers.

After calcVolts() has calculated and placed values in the voltage array, display the values in the arrays from within main() as follows:

voltage = current x resistance
42.48 10.63 4.00
126.56 14.89 8.50
79.26 13.21 6.00
...... ...... ......

Answers

#include <iostream>
#include <iomanip>
using namespace std;

int main()
{

const int max_num = 10;
int k;

double current[max_num], resistance[max_num], calc_volts[max_num];

for (k = 0; k < max_num; k++ )
{

cout << "Please Enter the ten values given for resistance:";
cout << "10.62, 14.89, 13.21, 16.55,\n\n 18.62, 9.47, 6.58, 18.32,";
cout << " 12.15, 3.98 or any ten values of your choice\n :";
cin >> current[k];

cout << "Now enter ten values for the resistance:\n";
cout << "4, 8.5, 6, 7.35, 9, 15.3, 3, 5.4, 2.9, 4.8.\n";
cout << " or any ten values of your choice.\n\n";
cin >> resistance[k];
}




for (k = 0; k < max_num; k++ )
{
calc_volts[k] = current[k] * resistance[k];
}


cout << "\nCurrent Resistance Volts" << endl;

for (k = 0; k< max_num; k++ )
{
cout << setw(7) << current[k] << setw(11) << resistance[k]
<< setw(11) << calc_volts[k] << endl;
}
}

]

.

Similar Solved Questions

1 answer
EgxQLydsflgQ/viewform?hr_submission=Chgl KuH6VgSEAJH 2 points Which situation could be modeled as a linear equation? 1) The value...
egxQLydsflgQ/viewform?hr_submission=Chgl KuH6VgSEAJH 2 points Which situation could be modeled as a linear equation? 1) The value of a car decreases by 10% every year. 2) The number of fish in a lake doubles every 5 years. 3) Two liters of water evaporate from a pool every day. 4) The amount of caff...
1 answer
A calendar year reporting company preparing its annual financial statements should use the phrase "For the...
A calendar year reporting company preparing its annual financial statements should use the phrase "For the twelve months ended as of December 31, 2017" in the heading of which financial statements? A. This heading would be used on the statement of cash flows. В. · This heading w...
1 answer
I need solution Required information The following information applies to the questions displayed below. drift" caused...
I need solution Required information The following information applies to the questions displayed below. drift" caused by failure to maintain precise heat levels during the production process. Rejects from the 100 percent testing program can be reworked to acceptable levels if the defect is drif...
1 answer
Need some help with these business law questions! Question 19 (1 point) When participating in mediation...
Need some help with these business law questions! Question 19 (1 point) When participating in mediation to resolve a dispute, it is okay for one of the parties to choose the mediator without involvement from the other party. False Question 20 (1 point) For a court to find that a tort has been commit...
1 answer
Mark Welsch deposits $6,500 in an account that earns interest at an annual rate of 4%,...
Mark Welsch deposits $6,500 in an account that earns interest at an annual rate of 4%, compounded quarterly. The $6,500 plus earned interest must remain in the account 5 years before it can be withdrawn. How much money will be in the account at the end of 5 years? (PV of $1, FV of $1, PVA of $1, and...
1 answer
A college gives aptitude tests in the sciences and the humanities to all incoming first year...
A college gives aptitude tests in the sciences and the humanities to all incoming first year students. If X and Y are the proportions of correct answers on the science and humanities exams, respectively, then the joint pdf of X, Y is given by: 1. otherwise a. Are X and Y independent? Why or why not?...
1 answer
A man pushing a mop across a floor causes it to undergo two displacements. The first...
A man pushing a mop across a floor causes it to undergo two displacements. The first has a magnitude of 152 cm and makes an angle of 128 with the positive x axis. The resultant displacement has a magnitude of 145 cm and is directed at an angle of 30.0° to the positive x axis. Find the magnitude ...
1 answer
Instructions The following accounts and their balances appear in the ledger of Goodale Propertes Inc. on...
Instructions The following accounts and their balances appear in the ledger of Goodale Propertes Inc. on June 30 of the current year 1 Common stock, $44 par 2,864,400.00 114,300.00 260,400.00 8,780,100.00 04,500.00 Paid-In Capital from Sale of Treasury Stock S Paid-In Capital in Excess of Par-Common...
1 answer
What is the equation written in point slope form if #f(6)=0# and #f(0)=6#?
What is the equation written in point slope form if #f(6)=0# and #f(0)=6#?...
1 answer
A company that produces pleasure boats has decided to expand one of its lines. Current facilities...
A company that produces pleasure boats has decided to expand one of its lines. Current facilities are insufficient to handle the increased workload, so the company is considering three alternatives, A (new location), B (subcontract), and C (expand existing facilities). Alternative A would involve su...
1 answer
Book: A Course in Enumeration. Author: Martin Aigner Chapter 1 Page:60 2.4 Let F(2)-「20 anz" with a0-0. Show that...
Book: A Course in Enumeration. Author: Martin Aigner Chapter 1 Page:60 2.4 Let F(2)-「20 anz" with a0-0. Show that F(z) has a composi- tional inverse F(-1) (2)-Ση20Pnz" with bo 0 if and only if ai + 0. , 71 2.4 Let F(2)-「20 anz" with a0-0. Show that F(z) has a co...
1 answer
S2, and (1 point) Let p be the joint density function such that px, y)- n...
s2, and (1 point) Let p be the joint density function such that px, y)- n R, the rectangle O s xs4,0 sy p(x,y0 outside R. Find the fraction of the population satisfying the constraint x 2 y fraction-...
1 answer
How do you convert #2x + 3y = 6# into polar form?
How do you convert #2x + 3y = 6# into polar form?...
1 answer
6. Let B(2) i + 22 4- 2iz (a) Find the smallest positive real value M...
6. Let B(2) i + 22 4- 2iz (a) Find the smallest positive real value M such that for every z on the closed unit disk D, B(2) <M. [6] (b) A particle on the complex plane is trapped within a wall built along the unit circle. It travels from -i to e3ri/4 and then bouncing from e3mi/4 to 1. Denote by ...
1 answer
Problem 2-3A Preparing and posting journal entries; preparing a trial balance LO C3, C4, A1, P1,...
Problem 2-3A Preparing and posting journal entries; preparing a trial balance LO C3, C4, A1, P1, P2 Denzel Brooks opened a Web consulting business called Venture Consultants and completes the following transactions in March. March 1 Brooks invested $185,000 cash along with $29,000 n office equipment...