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
#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;
}
Comments
Leave a comment