Answer to Question #201979 in C++ for Master j

Question #201979

Convert the pseudocode below to flowchart


Start

Declare Answer as character

Declare Count, sum, Veh_Weight as integer

Count = 0

sum = 0

for (Count < = 2000) do

Print "Do you wish to drive across the bridge, Y for yes and any other for No"

Read Answer

if (Answer == 'Y')then

Print "Enter weight of your vehicle"

Read Veh_weight

Sum = sum + Veh_weight


else

print "Thanks for stopping by. Maybe next time"

endif

end for

if (sum <= 15000) then

print "The bridge can maintain approximately another 50000KG

else

if (sum<= 30000) then

Print "The bridge has reached almost half its maximum weight capacity"

else

Print "The bridge is at its maximum weight capacity"

endif

endif

Stop


1
Expert's answer
2021-06-02T07:48:57-0400
#include <iostream>

std::string answer;
int sum, count, weight;

int main() {
  sum = count = 0;
  while (count <= 2000) {
    std::cout << "Do you wish to drive across the bridge, Y for yes and any other for no" << std::endl;
    std::cin >> answer;
    if (answer == "Y") {
      std::cout << "Enter weight of your vehicle:" << std::endl;
      std::cin >> weight;
      sum += weight;
    } else {
      std::cout << "Thanks for stopping by. Maybe next time" << std::endl;
    }
  }
  if (sum <= 15000) {
    std::cout << "The bridge can maintain approximately another 50000KG" << std::endl;
  } else if (sum <= 30000) {
    std::cout << "The bridge has reached almost half its maximum weight capacity" << std::endl;
  } else {
    std::cout << "The bridge is at its maximum weight capacity" << std::endl;
  }
  return 0;
} 

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog