Question

Make one program using Dev c++, and explain how program works Final Program Requirements: Program is...

Make one program using Dev c++, and explain how program works

Final Program Requirements:

Program is a modified version of the collection of formulas from Nested Conditional and IterativeStatements.

Convert the formulas previously done in the collection of formulas to equivalent functions.

Program can be subdivided into smaller units by creating functions that compute for different variables.

Requirements from Nested Conditional and Iterative Statements apply.

Test Walkthrough

1. Select a formula from the formula selection screen.

2. Select a variable from the variable selection screen.

3. Compute for the variable. Provide at least 2 sets of test data per variable.

4. Enter an invalid choice at the variable selection screen.

5. Repeat step 2 until all variables are computed.

6. Repeat step 1 until all formulas are demonstrated.

7. Enter an invalid choice at the formula selection screen.

7. Quit the program.

The previous answer for this question wasn't related to the question.

Formula 1: Volume of a rectangular prism

V = L x W x H

Formula 2: Volume of a pyramid

V = (L x W x H) / 3

0 0
Add a comment Improve this question Transcribed image text
Answer #1

code

#include<iostream>
using namespace std;
int volume,length,width,height;

void formula_1(int l,int w,int h)       //function for 1st formula
{
   volume=l*w*h;
   cout<<"volume is: "<<volume;

}


void formula_2(int l,int w,int h)       //function for second formula
{
   volume=(l*h*w)/3;
   cout<<"volume is: "<<volume;
}


void set_length()               //function for set length
{
   cout<<"kindly enter length: ";
   cin>>length;
}

void set_width()               //function for set width
{
   cout<<"kindly enter width: ";
   cin>>width;
}

void set_height()               // function for set height
{
   cout<<"kindly enter height: ";
   cin>>height;
}

int main()                   // main function
{
   char sel_f; //for selection of formula
   char sel_v; //for selection of variables
   int f_count=0;
   do
   {
  
       cout<<"\nkindly press 1 for formula 1\nor press 2 for formula 2\npress 3 to quit program: ";
       cin>>sel_f;               //for selection of formula
       switch (sel_f)
           {
               case '1':
                   {
                       cout<<"selected formula is:\nvolume=l*w*h\n";
                       int c_v=0;
                       do
                       {
                           cout<<"press 1 for set length\npress 2 for set width\npress 3 for select height: ";
                           cin>>sel_v;
                           switch (sel_v)
                               {
                                   f_count++;
                                   case '1':
                                       {
                                           set_length();
                                           c_v++;
                                           break;
                                       }
                                   case '2':
                                       {
                                           set_width();
                                           c_v++;
                                           break;
                                       }
                                   case '3':
                                       {
                                           set_height();
                                           c_v++;
                                           break;
                                       }
                                   default :
                                       cout<<"invalid choice of variable..,\n";
                               }
                   }
                   while(c_v<3);       //it will iterate untill all the variables are initialized
                   formula_1(length,width,height);
                   break;
                      
                   }
               case '2':
                   {
                       f_count++;
                       cout<<"selected formula is:\nvolume=(l*w*h)/3 \n";
                       int c_v=0;
                       do
                       {
                      
                           cout<<"press 1 for set length\npress 2 for set width\npress 3 for select height: ";
                           cin>>sel_v;
                          
                           switch (sel_v)
                               {
                                   case '1':
                                       {
                                           set_length();
                                           c_v++;
                                           break;
                                       }
                                   case '2':
                                       {
                                           set_width();
                                           c_v++;
                                           break;
                                       }
                                   case '3':
                                       {
                                           set_height();
                                           c_v++;
                                           break;
                                       }
                                   default :
                                       cout<<"invalid choice of variable..\n";
                               }
                       }
                       while(c_v<3);           //it will iterate untill all the variables are initialized
                       formula_2(length,width,height);
                       break;
                   }
               case '3':
                   return 0;
               default :
                   cout<<"invalid choice of formula..,\n";
                  
           }
   }
   while(f_count<2);               //it will iterate untill both the formulas are called
   return 0;
}


explanation:-


1)   in this programe we have used 2 formulas for calculating volume
2)   each formula takes three things a) length b) width c) height
3)   after selesting formual we will pass all the argument to it but first we have to initialze them
4)   we will initialize all the variable one by one when all the variables get intialized it will stop iterating
5)   like variales loop for formulas iterates untill al the formulas get used
6)   that's all about the above code...,
   good luck

\

COMMENT DOWN FOR ANY QUERIES AND,

LEAVE A THUMBS UP IF THIS ANSWER HELPS YOU.

Add a comment
Know the answer?
Add Answer to:
Make one program using Dev c++, and explain how program works Final Program Requirements: Program is...
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
  • Make one program using Dev c++, and explain how program works Final Program Requirements: Declare an...

    Make one program using Dev c++, and explain how program works Final Program Requirements: Declare an int variable and int array with four elements in the main program. Initial values for the intvariable and int array are hardcoded in the program. Declare an int pointer in the main program.Program shows the values of the integer variable and integer arrayelements. Program shows the addresses of the variable and each integer array element. Store addresses inpointers temporarily prior to displaying. The addresses...

  • Please make a JAVA program for the following using switch structures Write a program that simulates...

    Please make a JAVA program for the following using switch structures Write a program that simulates a simple Calculator program. The program will display menu choices to the user to Add, Subtract, Multiply and Divide. The program will prompt the user to make a selection from the choices and get their choice into the program. The program will use a nested if….else (selection control structure) to determine the user’s menu choice. Prompt the user to enter two numbers, perform the...

  • Help write down below program with C++ language!!! Please... The Cipher Program Requirements An interactive program...

    Help write down below program with C++ language!!! Please... The Cipher Program Requirements An interactive program is required that allows a user to encode text using any of three possible ciphers. The three ciphers you are to offer are: Caesar, Playfair and Columnar Transposition. • The program needs to loop, repeating to ask the user if they wish to play with Caesar, Playfair or Columnar Transposition until the user wishes to stop the program. •For encoding, the program needs to...

  • Activity 16-02 With proper indentation and comments, With proper interface/menu on the monitor Write C program...

    Activity 16-02 With proper indentation and comments, With proper interface/menu on the monitor Write C program of the following problem. This question involve repetition: while, and for statements This question involve selection: Don't use switch, use IF Marks is based on comments, indentation and interface/menu. You must try Choose any one value of j to print screen the following i Three input: num less than j, 21 and any valid number three input: A, B and X. Question: 1.0 From...

  • I need help solving these questions,please don’t know how to solve it by using matlab.!

    i need help solving these questions,please don’t know how to solve it by using matlab.! Solve the following questions Ol: You are required to develop a script to calculate the volume of a pyramid, which is 1/3 *base *height, where the base is length *width. Prompt the user to enter values for the length, width, and height, and then calculate the volume of the pyramid. When the user enters each value, he or she will then also be prompted to...

  • C++ programming For this assignment, write a program that will act as a geometry calculator. The...

    C++ programming For this assignment, write a program that will act as a geometry calculator. The program will be menu-driven and should continue to execute as long as the user wants to continue. Basic Program Logic The program should start by displaying a menu similar to the following: Geometry Calculator 1. Calculate the area of a circle 2. Calculate the area of a triangle 3. Quit Enter your choice(1-3): and get the user's choice as an integer. After the choice...

  • I'm falling behind on my hw and I can really use a hand with using structures...

    I'm falling behind on my hw and I can really use a hand with using structures in C,++ C++ Object Oriented Programming Programming Assignment #4 Structures Create a structure representing a student. The member variables should include student name, student ID, and four test grades for the student (an array of four grades as a member variable). Prompt the user to enter the name, ID and the four test results. Store all the data in the structure. Calculate the average...

  • Module 6 - Cash Register (10 Points) We are going to write a program that simulates...

    Module 6 - Cash Register (10 Points) We are going to write a program that simulates a customer's transaction at a cash register. You will organize your code using functions. Each of the functions below counts for 2 points. You must create functions allowing the user to: 1. Add an item to the order. No name or list of items is needed simply prompt the user for a dollar amount to add. 2. Clear all transactions. Set the amount of...

  • C++ HELP I need help with this program. I have done and compiled this program in a single file called bill.cpp. It works fine. But I need to split this program in three files 1. bill.h = contains the...

    C++ HELP I need help with this program. I have done and compiled this program in a single file called bill.cpp. It works fine. But I need to split this program in three files 1. bill.h = contains the class program with methods and variables 2. bill.cpp = contains the functions from class file 3. main.cpp = contains the main program. Please split this program into three files and make the program run. I have posted the code here. #include<iostream>...

  • This is java and make simple program. CPSC 1100. Thanks CSPS 1100 Lab 4 ay total...

    This is java and make simple program. CPSC 1100. Thanks CSPS 1100 Lab 4 ay total Also I would need a new name for the daubles. An example here might be double tRtalD-caradd xD, YD) 1. (a) We are going to begin with some simple math, reading input, and formatted output. Create a class called MuCalsustec Yau will not have an instance variable. Since you have no instance variables to initialize, you do nat need a constructar. Do NOT create...

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