Question

In: Computer Science

I need a Flowgorithm chart of this #include using namespace std; int main() {    float...

I need a Flowgorithm chart of this

#include
using namespace std;

int main()
{
   float CISBook[] = {55.5,35.8,67.5};
   float MATHBook[] = {25.5, 54.5};
   float MECBook[] = {65.0,75.5,86.8};
   float sumCIS=0, sumMATH = 0, sumMEC = 0;
  
      
   for (int i=0; i<4; i++)
   {sumCIS += CISBook[i];}
  
   for (int i=0; i<3; i++)
   {sumMATH += MATHBook[i];}
  
   for (int i=0; i<4; i++)
   {sumMEC += MECBook[i];}
  
   cout<<"\nTotal for CIS Books: Programming 1; Intro to Networking; Javascript"<    for (int i=0; i<4; i++)
   cout<    cout<<"\nCost of CIS books: "<   
   cout<<"\nTotal for Math Books: Calculus; Intro to Geometry"<    for(int i=0; i<3; i++)
   cout<    cout<<"\nCost of Math book:"<   
   cout<<"\nTotal for MEC Books: Statics; Intro to Ind. Process; Hydraulics and Pneumatics"<    for (int i=0; i<4; i++)
   cout<    cout<<"\nCost of MEC books: "<   
   cout<<"\nTotal sale amount is: "<<(sumCIS+sumMATH+sumMEC)<   
   cout<<"\n20% paid by financial aid:"<   
   cout<<"\nTotal amount student must pay: "<<(sumCIS + sumMATH + sumMEC)-(sumCIS+sumMATH+sumMEC)*.20<   
return 0;
}

Solutions

Expert Solution

Greetings !

Flowchart generated by Flowgorithm application of given program in C++

Screenshot of the output generated by Flowgorithm Application

// pseudocode generated by flowgorithm application :

function Main

    CISBook[0] = 55.5

    CISBook[1] = 35.8

    CISBook[2] = 67.5

    MATHBook[0] = 25.5

    MATHBook[1] = 54.5

    MECBook[0] = 65

    MECBook[1] = 75.5

    MECBook[2] = 86.8

    sumCIS = 0

    sumMATH = 0

    sumMEC = 0

    loop i from 0 to 2

        sumCIS = sumCIS + CISBook[i]

    end loop

    loop i from 0 to 1

        sumMATH = sumMATH + MATHBook[i]

    end loop

    loop i from 0 to 2

        sumMEC = sumMEC + MECBook[i]

    end loop

    output "Total for CIS Books: Programming 1; Intro to Networking; Javascript"

    loop i from 0 to 2

        output CISBook[i]

    end loop

    output "Cost of CIS books: " + sumCIS

    output "Total for Math Books: Calculus; Intro to Geometry"

    loop i from 0 to 1

        output MATHBook[i]

    end loop

    output "Cost of MATH books: " + sumMATH

    output "Total for MEC Books: Statics; Intro to Ind. Process; Hydraulics and Pneumatics"

    loop i from 0 to 2

        output MECBook[i]

    end loop

    output "Cost of MEC books: " + sumMEC

    output "Total sale amount is: " + sumCIS + sumMATH + sumMEC

    output "20% paid by financial aid: "

    output "Total amount student must pay: " + sumCIS + sumMATH + sumMEC - (sumCIS + sumMATH + sumMEC) * 0.2

end function

// C++ source code generated by Flowgorithm application

#include <iostream>
#include <sstream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>

using namespace std;

// Headers
string toString (double);
int toInt (string);
double toDouble (string);

int main() {
vector<double> CISBook(3);
  
CISBook[0] = 55.5;
CISBook[1] = 35.8;
CISBook[2] = 67.5;
vector<double> MATHBook(2);
  
MATHBook[0] = 25.5;
MATHBook[1] = 54.5;
vector<double> MECBook(3);
  
MECBook[0] = 65;
MECBook[1] = 75.5;
MECBook[2] = 86.8;
double sumCIS;
  
sumCIS = 0;
double sumMATH;
  
sumMATH = 0;
double sumMEC;
  
sumMEC = 0;
int i;
  
for (i = 0 ; i <= 2 ; i += 1) {
sumCIS = sumCIS + CISBook[i];
}
for (i = 0 ; i <= 1 ; i += 1) {
sumMATH = sumMATH + MATHBook[i];
}
for (i = 0 ; i <= 2 ; i += 1) {
sumMEC = sumMEC + MECBook[i];
}
cout << "Total for CIS Books: Programming 1; Intro to Networking; Javascript" << endl;
for (i = 0 ; i <= 2 ; i += 1) {
cout << CISBook[i] << endl;
}
cout << "Cost of CIS books: " << sumCIS << endl;
cout << "Total for Math Books: Calculus; Intro to Geometry" << endl;
for (i = 0 ; i <= 1 ; i += 1) {
cout << MATHBook[i] << endl;
}
cout << "Cost of MATH books: " << sumMATH << endl;
cout << "Total for MEC Books: Statics; Intro to Ind. Process; Hydraulics and Pneumatics" << endl;
for (i = 0 ; i <= 2 ; i += 1) {
cout << MECBook[i] << endl;
}
cout << "Cost of MEC books: " << sumMEC << endl;
cout << "Total sale amount is: " << sumCIS + sumMATH + sumMEC << endl;
cout << "20% paid by financial aid: " << endl;
cout << "Total amount student must pay: " << sumCIS + sumMATH + sumMEC - (sumCIS + sumMATH + sumMEC) * 0.2 << endl;
}

// The following implements type conversion functions.

string toString (double value) { //int also
stringstream temp;
temp << value;
return temp.str();
}

int toInt (string text) {
return atoi(text.c_str());
}

double toDouble (string text) {
return atof(text.c_str());
}


Related Solutions

#include <iostream> #include <iomanip> using namespace std; int main() {             float miles;   //miles traveled          &nbsp
#include <iostream> #include <iomanip> using namespace std; int main() {             float miles;   //miles traveled             float hours;   //time in hours             float milesPerHour; //calculated miles per hour             cout << "Please input the Miles traveled" << endl;             cin >> miles;             cout << "Please input the hours traveled" << endl;             cin >> hours;                         milesHours = miles / hours; cout << fixed << showpoint << setprecision(2);             cout << "Your speed is " <<...
9. #include <fstream> #include <iostream> using namespace std; int main() {     float bmi;     ifstream...
9. #include <fstream> #include <iostream> using namespace std; int main() {     float bmi;     ifstream inFile;     inFile.open("bmi.txt");     while (!inFile.eof())       {          inFile >> bmi;          if( bmi < 18.5)           {               cout << bmi << " is underweight " ;           }         else if( bmi >= 18.5 && bmi <= 24.9)           {               cout << bmi << " is in normal range " ;           }         else if( bmi >= 25.0 &&...
9. #include <fstream> #include <iostream> using namespace std; int main() { float bmi; ifstream inFile; inFile.open("bmi.txt");...
9. #include <fstream> #include <iostream> using namespace std; int main() { float bmi; ifstream inFile; inFile.open("bmi.txt"); while (!inFile.eof()) { inFile >> bmi; if( bmi < 18.5) { cout << bmi << " is underweight " ; } else if( bmi >= 18.5 && bmi <= 24.9) { cout << bmi << " is in normal range " ; } else if( bmi >= 25.0 && bmi <= 29.9) { cout << bmi << " is overweight " ; } else...
#include <cstring> #include <stdio.h> #include <iostream> using namespace std; int main() {        const int...
#include <cstring> #include <stdio.h> #include <iostream> using namespace std; int main() {        const int SIZE = 20;     char str[SIZE];     char str1[SIZE];     int n;     int k =1;        printf("Enter a word: \n");     fgets(str,SIZE,stdin);     printf("Enter another word: \n");     fgets(str1,SIZE,stdin);        if (str1[strlen(str1) - 1] == '\n')     {         str1[strlen(str1)-1] = '\0';     }     if (str[strlen(str) - 1] == '\n')     {         str[strlen(str)-1] = '\0';     }      ...
Complete the following program #include<iostream> #include<iomanip> #include<fstream> using namespace std; int main() { // I -...
Complete the following program #include<iostream> #include<iomanip> #include<fstream> using namespace std; int main() { // I - Declaring a five by five array /* II - Read data from data.txt and use them to create the matrix in the previous step*/    // III - Count and print the number of even integers in the matrix. /* IV - Calculate and print the sum of all integers in the columns with an even index value. Please note the column index begins...
#include <iostream> using namespace std; int main() {     int hour;     int min;     for (hour = 1;...
#include <iostream> using namespace std; int main() {     int hour;     int min;     for (hour = 1; hour <= 12; hour++)     {         for (min = 0; min <= 59; min++)         {             cout << hour << ":" << min << "AM" << endl;         }     }       return 0; } 1.      Type in the above program as time.cpp. Add a comment to include your name and date. Compile and run. 2.      What is the bug or logic error in the above program? Add the...
Fill in the code only using pointer variables #include using namespace std; int main() { int...
Fill in the code only using pointer variables #include using namespace std; int main() { int longside; // holds longside (length) int wideside; // holds wideside(width) int total; // holds total (area) int *longsidePointer = nullpointer; // int pointer which will be set to point to length int *widthPointer = nullpointer; // int pointer which will be set to point to width cout << "Please input the longside of the rectangle" << endl; cin >> longside; cout << "Please input...
#include <iostream> #include <iomanip> using namespace std; int main() {     int studentid, numberreverse[20], count =...
#include <iostream> #include <iomanip> using namespace std; int main() {     int studentid, numberreverse[20], count = 0, maximum = 0, minimum = 0;     cout << "Enter your student ID number: ";     cin >> studentid;     cout << "Student ID Number = " << studentid << endl;     while (studentid != 0)     {          numberreverse[count] = studentid % 10;          if (count == 0)          {              minimum = numberreverse[count];              maximum = minimum;          }          else...
#include <iostream> #include "lib.hpp" using namespace std; int main() {    // declare the bool bool...
#include <iostream> #include "lib.hpp" using namespace std; int main() {    // declare the bool bool a = true; bool b= true;    //Print the Conjunction function cout<<"\n\nConjunction Truth Table -"<<endl; cout<< "\nP\tQ\t(P∧Q)" <<endl; cout<< a <<"\t"<< b <<"\t"<< conjunction(a,b) <<endl; cout<< a <<"\t"<< !b <<"\t"<< conjunction(a,!b) <<endl; cout<< !a <<"\t"<< b <<"\t"<< conjunction(!a,b) <<endl; cout<< !a <<"\t"<< !b <<"\t"<< conjunction(!a,!b)<<endl;    //Print the Disjunction function cout<<"\n\nDisjunction Truth Table -"<<endl; cout<< "\nP\tQ\t(PVQ)" <<endl; cout<< a <<"\t"<< b <<"\t"<< disjunction(a,b) <<endl;...
#include <iostream> #include "lib.hpp" using namespace std; int main() {    // declare the bool bool...
#include <iostream> #include "lib.hpp" using namespace std; int main() {    // declare the bool bool a = true; bool b= true;    //Print the Conjunction function cout<<"\n\nConjunction Truth Table -"<<endl; cout<< "\nP\tQ\t(P∧Q)" <<endl; cout<< a <<"\t"<< b <<"\t"<< conjunction(a,b) <<endl; cout<< a <<"\t"<< !b <<"\t"<< conjunction(a,!b) <<endl; cout<< !a <<"\t"<< b <<"\t"<< conjunction(!a,b) <<endl; cout<< !a <<"\t"<< !b <<"\t"<< conjunction(!a,!b)<<endl;    //Print the Disjunction function cout<<"\n\nDisjunction Truth Table -"<<endl; cout<< "\nP\tQ\t(PVQ)" <<endl; cout<< a <<"\t"<< b <<"\t"<< disjunction(a,b) <<endl;...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT