Question

Engr 1732 Lab7 statistics and10r. 2dimensioned Vectors Add ONu 7.) write a c program that creates the following eight two dimensional random number (a) the voltage vector VI10 contains n xm voltages between 100 and 10oo volts, (where n. arows, maa columns) (b) the current vector I00 contains nxm currents between 10 and 50 Amps, (c) the phase vector PHIlll contains nxm phase angles between o and 45 degrees (Note the degrees must be converted into radians before using any formulas) (d) The power vector units of Watts) is given by 00 cos (PH00 M P1/180); (e) The reaction vector (units of vARs) is given by Q00 V00 I00 sin(PH00 M PI/180); The Bill vector (units of dollars) is given by Cin>> rate Bill00 rate VOD 00; where rate is the cost of electricity per kilowatt- hour (see instructor for rate entered by user (g) Finally, the user will enter a desired power factor see instructor for this value and your program will calculate the shunt capacitor required to create the new desired power factor, and the corresponding reduced power bill. Cin>> PF; COO (Q00-P00 tan acos (PF))/(377 pow(VIJO, 2)); New bill [10a sqrt(pow(P002) (Q00- P00 tan(acos(PF) (Qll P00 tan(acos(PF)))); Note you will need a double for loop to carry out the above calculations. Your program should print out the original values of Pllll, Qll0, bill00, C0[l, New bill00 Int seed time(NULL); srand(seed);
0 0
Add a comment Improve this question Transcribed image text
Answer #1

C++ CODE

#include<iostream>
#include<stdlib.h>
#include<ctime>
#include<math.h>
#include<iomanip>
int randNum(int min, int max);
using namespace std;
int main()
{
   //random number seed
   srand(time(NULL));
  
   //array variables
   double V[4][5];
   double I[4][5];
   double PH[4][5];
   double P[4][5];
   double Q[4][5];
   double bill[4][5];
   double C[4][5];
   double New_bill[4][5];
   double rate;
   double PF;
   int i,j; //for looping
  
   //initializing v
   for(i=0; i<4; i++)
   {
       for(j=0; j<5; j++){
      
       V[i][j]=randNum(100, 1000); //calling randNum()
      
       }
   }
  
   //initializing I
   for(i=0; i<4; i++)
   {
       for(j=0; j<5; j++){
      
       I[i][j]=randNum(10, 50);}
   }
  
   //calculating PH
   for(i=0; i<4; i++)
   {
       for(j=0; j<5; j++){
      
       PH[i][j]=randNum(0, 45) * (22/1260);}
   }
  
   //calculating Power vector
   for(i=0; i<4; i++)
   {
       for(j=0; j<5; j++){
      
       P[i][j] = V[i][j] * I[i][j] * cos(PH[i][j]);}
   }
  
   //calculating reaction vector
   for(i=0; i<4; i++)
   {
       for(j=0; j<5; j++){
      
       Q[i][j] = V[i][j] * I[i][j] * sin(PH[i][j]);}
   }

cout<<"Enter rate for bill calculation: ";
cin>>rate;

//calculating bill
for(i=0; i<4; i++)
   {
       for(j=0; j<5; j++)
       {
      
       bill[i][j] = rate * V[i][j] * I[i][j] ;}
   }
   cout<<"\n\nEnter Power factor: "; //inputting PF from user
   cin>>PF;
  
   //calculating shunt capacitor and new bill
   for(i=0; i<4; i++)
   {
       for(j=0; j<5; j++)
       {
      
       C[i][j] = (Q[i][j] - P[i][j] * tan(acos(PF))) / (377 * pow(V[i][j], 2));
       New_bill[i][j] = sqrt(pow(P[i][j], 2) + (Q[i][j] - P[i][j] * tan(acos(PF)))*(Q[i][j]-P[i][j]*tan(acos(PF))));
       }
   }
  
   //printing all the values
   cout<<"Power vector reaction vector Bill Shunt Capacitor New Bill\n\n"; //header
   for(i=0; i<4; i++)
   {
       for(j=0; j<5; j++)
       cout<<P[i][j]<<setw(15)<<Q[i][j]<<setw(20)<<bill[i][j]<<setw(20)<<C[i][j]<<setw(17)<<New_bill[i][j]<<"\n"; //data
   }
}
  
//randNum() function
int randNum(int min, int max)
{
  
   return (min + (rand() % (max - min + 1)));
  
  
}

OUTPUT

E\Program Files Cplusplus workspacel volt.exe nter rate for bill calculation: 5.5 nter Power factor: .003 ower vectOr reactio

Add a comment
Know the answer?
Add Answer to:
Write a C++ program that creates the following eight two dimensional random number vector: (a) the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write the Code in C program. Create a random password generator that contains a user-specified number...

    Write the Code in C program. Create a random password generator that contains a user-specified number of characters. Your program should prompt the user for the desired length of the password. Length of password: To create your password, use the random number generator in the stdlib.h C library. To generate random numbers, you will need the srand() and rand() functions. srand(seed) is used to "seed" the random number generator with the given integer, seed. Prompt the user for the seed...

  • c++ help Write a program that: Creates two finite arrays of size 10 These arrays will...

    c++ help Write a program that: Creates two finite arrays of size 10 These arrays will serve as a storing mechanism for student grades in Classes A and B Uses a loop to populate the arrays with randomly generated numbers from 0 to 100.These numbers will represent student grades. Compute average grade of each class. Finally, output the two arrays and the message with two averages and best class. ("Class A average is: 65.43; class B average is: 68.90. Class...

  • Write a C++ program that uses a structure to store the following inventory information in a...

    Write a C++ program that uses a structure to store the following inventory information in a file: ⦁   Item description, Quantity on hand, Wholesale cost, Retail cost, and Date added to inventory. ⦁   Use a char array for item description and date. ⦁   The program should have a menu that allows the user to perform the following tasks: i.   Add a new record at the end of the file. ii.   Display any record in the file. iii.   Change any record...

  • Please, I need help with program c++. This is a chutes and ladders program. The code...

    Please, I need help with program c++. This is a chutes and ladders program. The code must be a novel code to the specifications of the problem statement. Thank you very much. Assignment Overview This program will implement a variation of the game “chutes and ladders” or “snakes and ladders:” https://en.wikipedia.org/wiki/Snakes_and_Ladders#Gameplay. Just like in the original game, landing on certain squares will jump the player ahead or behind. In this case, you are trying to reach to bottom of the...

  • For this c++ assignment, Overview write a program that will process two sets of numeric information....

    For this c++ assignment, Overview write a program that will process two sets of numeric information. The information will be needed for later processing, so it will be stored in two arrays that will be displayed, sorted, and displayed (again). One set of numeric information will be read from a file while the other will be randomly generated. The arrays that will be used in the assignment should be declared to hold a maximum of 50 double or float elements....

  • Write a C++ program named, gradeProcessor.cpp, that will do the following tasks: -Print welcome message -Generate...

    Write a C++ program named, gradeProcessor.cpp, that will do the following tasks: -Print welcome message -Generate the number of test scores the user enters; have scores fall into a normal distribution for grades -Display all of the generated scores - no more than 10 per line -Calculate and display the average of all scores -Find and display the number of scores above the overall average (previous output) -Find and display the letter grade that corresponds to the average above (overall...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT