Project1 VW type engine component analyzer Background: Here are some fun facts r
ID: 3852515 • Letter: P
Question
Project1 VW type engine component analyzer Background: Here are some fun facts related to the project. The early 70's VW beetle came with a 1585cc air cooled motor that produced 50HP. The engine is highly customizable and can be downsized for improved mileage or upsized for massive HP gains. Some engine components are bolt on. Some components require that you take your components to the machine shop for work before you can bolt them on. Either way, you will need to be mindful of the engine's compression ratio (cr). When the cris too low you leave power and mileage on the table. If the cr is too high, your engine will be prone to preignition, otherwise known as knock or ping. You will not be tested on the background Understanding of the background is not necessary for project completion. C++ Objectives: In this homework, we will explore some of the basics of C++ programming. In particular, we will practice working with: multiple data type variable declarations, input with cin, output with cout including escape characters and formatting, arithmetic operations, boolean logic, while and do while loops, if else, nested if-else-if and/or switch branching Tasks: You will need to compute several quantities. 1. The first is the engine volume (vol engine): (4 (bore/2)n2) pi stroke)/1000 2. The second is the combustion chamber volume (vol chamber) (((3/2) ((bore/2)A2)*pi)/1000)+head volume 3. The final quantity is the compression ratio (comp ratio): (engine volume/4/combustion chamber volume)-1 Additionally, the project has several menus that will operate in while or do while loops. After a user has selected all the engine components, the program will print out the engine statistics and any applicable warning messages. There is a closing menu that will take a user back to the top menu or allow the user to quit the program. Make sure your program handles invalid menu choices. There are some fixed constants that will guide the Boolean logic of the warning messages. All pistons 88mm and larger require head machine work. All pistons 90.5mm and larger require case machine work. All strokes 78mm and larger require case machine work. All compression ratios 8.8 and higher are too high. All compression ratios 7.8 and lower are too low The menus will accept menu pick q at any prompt as a way to terminate the program. Invalid menu picks simply redisplay the current menu. As a no extra credit challenge, you may implement menu pick z at any prompt as a way to take the user up one level (when applicable) in the menusExplanation / Answer
Answer:
#include <iostream>
#include <iomanip>
#include <math.h>
using namespace std;
int main() {
//Constants
double PI = 3.14159;
//Variables
double vol_engine;
double vol_chamber;
int vol_head;
int stroke;
double bore;
double comp_ratio;
char menu_pic = 'Z';
cout<<"Customize your air cooled type I VW Engine"<<endl;
//do-while loop for the Top-Level Menu
do{
menu_pic = 'Z';
bore = 0;
stroke = 0;
comp_ratio = 0;
//do-while loop for crankshaft menu
do{
menu_pic = 'Z';
cout<<fixed<<setprecision(1)<<"Select Crankshaft 0000cc "<<comp_ratio<<":1"<<endl;
cout<<" a. 69 mm stock"<<endl;
cout<<" b. 74 mm stroker"<<endl;
cout<<" c. 76 mm "<<endl;
cout<<" d. 78 mm "<<endl;
cout<<" e. 82 mm "<<endl;
cin>>menu_pic;
switch(menu_pic) {
case 'a':
stroke = 69;
break;
case 'b':
stroke = 74;
break;
case 'c':
stroke = 76;
break;
case 'd':
stroke = 78;
break;
case 'e':
stroke = 82;
break;
case 'q':
break;
default:
cout<<"oops!, Invalid Input"<<endl;
}
}
while(menu_pic != 'a' && menu_pic != 'b' && menu_pic != 'c' && menu_pic != 'd' && menu_pic != 'e'
&& menu_pic != 'q');
if(menu_pic == 'q')
break;
//do-while loop for pistons menu
do{
menu_pic = 'Z';
cout<<fixed<<setprecision(1)<<"Select Pistons 0000cc "<<comp_ratio<<":1"<<endl;
cout<<" a. 83 mm underbore"<<endl;
cout<<" b. 85.5mm stock"<<endl;
cout<<" c. 88 mm overbore"<<endl;
cout<<" d. 90.5mm "<<endl;
cout<<" e. 92 mm "<<endl;
cout<<" f. 94 mm "<<endl;
cin>>menu_pic;
switch(menu_pic) {
case 'a':
bore = 83;
break;
case 'b':
bore = 85.5;
break;
case 'c':
bore = 88;
break;
case 'd':
bore = 90.5;
break;
case 'e':
bore = 92;
break;
case 'f':
bore = 94;
break;
case 'q':
break;
default:
cout<<"oops!, Invalid Input"<<endl;
}
}
while(menu_pic != 'a' && menu_pic != 'b' && menu_pic != 'c' && menu_pic != 'd' && menu_pic != 'e'
&& menu_pic != 'f' && menu_pic != 'q');
if(menu_pic == 'q')
break;
//Calculating engine volume
vol_engine = (4*pow((bore/2),2)*PI*stroke)/1000;
//do-while loop for heads menu
do{
menu_pic = 'Z';
cout<<fixed<<setprecision(1)<<"Select Heads "<<vol_engine<<"cc "<<comp_ratio<<":1"<<endl;
cout<<" a. 51 cc stock"<<endl;
cout<<" b. 53 cc stage I"<<endl;
cout<<" c. 56 cc stage II"<<endl;
cout<<" d. 60 cc stage III"<<endl;
cin>>menu_pic;
switch(menu_pic) {
case 'a':
vol_head = 51;
break;
case 'b':
vol_head = 53;
break;
case 'c':
vol_head = 56;
break;
case 'd':
vol_head = 60;
break;
case 'q':
break;
default:
cout<<"oops!, Invalid Input"<<endl;
}
}
while(menu_pic != 'a' && menu_pic != 'b' && menu_pic != 'c' && menu_pic != 'd' && menu_pic != 'q');
if(menu_pic == 'q')
break;
vol_chamber = (((3/2)*pow((bore/2),2)*PI)/1000)+vol_head;
comp_ratio = (vol_engine/4/vol_chamber) + 1;
cout<<fixed<<setprecision(1)<<"your engine is "<<bore<<" bore x "<<stroke<<" stroke"<<endl;
cout<<"your displacement is "<<vol_engine<<"cc"<<endl;
cout<<"your heads have "<<vol_chamber<<"cc "<<"combustion chambers"<<endl;
cout<<fixed<<setprecision(1)<<"your compression ratio is "<<comp_ratio<<":1"<<endl;
if(comp_ratio <= 7.8) {
cout<<"ÿour compression ratio is too low"<<endl;}
else if(comp_ratio >= 8.8) {
cout<<"your compression ratio is too high"<<endl;
}
bool needHeadWork = false;
bool needCaseWork = false;
if(bore >= 88 && bore < 90.5){
needHeadWork = true;
}
else if(bore >= 90.5){
needCaseWork =true;
}
if(stroke >= 78){
needCaseWork = true;
}
if(needCaseWork == true && needHeadWork == true){
cout<<"you will need case and head work"<<endl;
}
else if(needHeadWork == true){
cout<<"ÿou will need head work"<<endl;
}
else if(needCaseWork == true){
cout<<"you will need case work"<<endl;
}
//do-while loop for re-looping
do{
menu_pic = 'Z';
cout<<fixed<<setprecision(1)<<"ReSelect Components "<<vol_engine<<"cc "<<comp_ratio<<":1"<<endl;
cout<<" a. yes"<<endl;
cout<<" b. no (quit)"<<endl;
cin>>menu_pic;
switch(menu_pic){
case 'a' :
break;
case 'b' :
break;
default:
cout<<"oops!, Invalid Input"<<endl;
}
}
while(menu_pic != 'a' && menu_pic != 'b' && menu_pic != 'q');
}
while(menu_pic != 'b' && menu_pic != 'q');
cout<<"Thanks for using Engine build v1.0";
}
----------------------------------------------------------------------------------------------------------
OUTPUT:
Customize your air cooled type I VW Engine
Select Crankshaft 0000cc 0.0:1
a. 69 mm stock
b. 74 mm stroker
c. 76 mm
d. 78 mm
e. 82 mm
a
Select Pistons 0000cc 0.0:1
a. 83 mm underbore
b. 85.5mm stock
c. 88 mm overbore
d. 90.5mm
e. 92 mm
f. 94 mm
a
Select Heads 1493.3cc 0.0:1
a. 51 cc stock
b. 53 cc stage I
c. 56 cc stage II
d. 60 cc stage III
ayour engine is 83.0 bore x 69 stroke
your displacement is 1493.3cc
your heads have 56.4cc combustion chambers
your compression ratio is 7.6:1
ÿour compression ratio is too low
ReSelect Components 1493.3cc 7.6:1
a. yes
b. no (quit)
b
Thanks for using Engine build v1.0
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.