Skip to main content

c++ Programming -11a -do/while

In this programming, we will cover everything we have cover in our c++ programming including switch case, if/else, gotoxy coordination, do/while and system clear
First, code for the header file stdafx.h:
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//

#pragma once


#include 
#include 
#include 
#include 
#include 
#include 
using namespace std;

// TODO: reference additional headers your program requires here


Name the main file anyhow you like.
Programming codes for the main file below:

// IntAirways.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"


void menu();
void main();
void load_flight1();
void load_flight2();
void load_flight3();
void generate_report();
void exit();

int i=0, y=0, x=0;  //setup lools for element of parcels.

int space1=0, space2=0, space3=0; // for calculating space left over
				  // after entering parcels.

int load_limit1;  // load_limit for flight no.1. 
int weight1=0; //reading of parcels for flight no.1.
int totweight1=0;  // totalweight for flight no.1 initailised
int total=0;
float average_utilisation; // average for all the flights.
float total_Revenue; // revenue for all the flighs.
int choice;  // reading for entering choice enter meun.

//utilisations for the flights
float flight_utilisation1,flight_utilisation2, flight_utilisation3; 

//revenue for the flights.
float flight_revenue1, flight_revenue2, flight_revenue3;

int load_limit2; //load_limit for flight no.2.
int weight2=0;  // reading of parcels for flight no.2.
int totweight2=0;  // totalweight for flight no.2 initailised.
int load_limit3;  // load limit for flight no.3.
int weight3=0;  // reading of parcels for flight no.3.
int totweight3=0; //total weight for flight no.2 initailised.

//to resolve the coordination errors-identifer not found
void gotoxy(int x, int y)
{
COORD coord;
coord.X = x;
coord.Y = y;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
}

void menu()

{
//clrscr();
system("cls");
gotoxy(15,5);
cout<<"========================================= ";
gotoxy(15,6);
cout<<"Y										Y";
gotoxy(15,7);
cout<<"Y	INTERSCORT AIRWAYS LTD				Y";
gotoxy(15,8);
cout<<"Y										Y";
gotoxy(15,9);
cout<<"========================================= ";
gotoxy(15,10);
cout<<"Y										Y";
gotoxy(15,11);
cout<<"Y	1. Load_flight1 to Aircraft			Y";
gotoxy(15,12);
cout<<"Y										Y";
gotoxy(15,13);
cout<<"Y	2. load_flight2 to Aircraft			Y";
gotoxy(15,14);
cout<<"Y										Y";
gotoxy(15,15);
cout<<"Y	3. load_flight3 to Aircraft			Y";
gotoxy(15,16);
cout<<"Y										Y";
gotoxy(15,17);
cout<<"Y	4. Generate_report      			Y";
gotoxy(15,18);
cout<<"Y										Y";
gotoxy(15,19);
cout<<"Y	5. Exit								Y";
gotoxy(15,20);
cout<<"Y										Y";
gotoxy(15,21);
cout<<"=========================================Y";
}

//main function
void main()
{

//clrscr();
system("cls");

do
{
menu();
gotoxy(15,22);
cout<<"Enter your choice:";
cin>>choice;

switch(choice)
{
  case 1: load_flight1();
	break;
  case 2: load_flight2();
	break;
  case 3: load_flight3();
	break;
  case 4: generate_report();
	break;
  case 5: exit();
  	break;
  default: cout<<"Invalid menu choice"<>load_limit1;

do

{

cout<<"\nEnter the weight of parcel no."<>weight1;
i=i++;

totweight1=weight1+totweight1;  // calculations for total weight.

// calculations for space left over after entering parcels.
space1=load_limit1-totweight1;
space1+1; // increment space left over.

if (load_limit1-totweight1<0)
{

}

cout<<"\nspace left is:"<load_limit1)
{

cout<<"\n********Parcel rejected - refer to next flight.******";

totweight1=totweight1-weight1; //weight is substruct from total weight.

i=i-1;   // array of parcels is decrement from loop.

if (weight1==0)
weight1=weight1-1;  //decrement parcel.


}


}


while (weight1!=0);

//clrscr();
system("cls");

do
{
menu();
gotoxy(15,22);
cout<<"Enter your choice:";
cin>>choice;


switch(choice)
{
  case 1: load_flight1();
	break;
  case 2: load_flight2();
	break;
  case 3: load_flight3();
	break;
  case 4: generate_report();
	break;
  case 5: exit();
  	break;
  default: cout<<"Invalid menu choice"<>load_limit2;

do
{

cout<<"\nEnter the weight of parcel no."<>weight2;

y=y++;

totweight2=weight2+totweight2; // calculation for total weight.

// calculations for space left over after enter parcels.
space2=load_limit2-totweight2; 
space2+1; //increment loop for space left.

if (load_limit2-totweight2<0)
{

}

cout<<"\nspace left is:"<load_limit2)
{

cout<<"\n********Parcel rejected - refer to next flight.******";

totweight2=totweight2-weight2;  //weight is substruct from total weight.

y=y-1;  // array of parcels is decrement from loop.

if (weight2==0)
weight2=weight2-1;  //decrement reading parcel.
}


}
while (weight2!=0);

{


//clrscr();
system("cls");

do
{
menu();
gotoxy(15,22);
cout<<"Enter your choice:";
cin>>choice;


switch(choice)
{
  case 1: load_flight1();
	break;
  case 2: load_flight2();
	break;
  case 3: load_flight3();
	break;
  case 4: generate_report();
	break;
  case 5: exit();
  	break;
  default: cout<<"Invalid menu choice"<>load_limit3;

do

{

cout<<"\nEnter the weight of parcel no."<>weight3;

x=x++;

totweight3=weight3+totweight3; // calculations for total weight.

// calculations for space left over after enter parcels.
space3=load_limit3-totweight3;
space3+1;  //increment loop for space left.

if (load_limit3-totweight3<0)
{

}

cout<<"\nspace left is:"<load_limit3)
{
total=weight3;
cout<<"\n********Parcel not accepted.******";
totweight3=totweight3-total; //weight is substruct from total weight.

x=x-1;  // array of parcels is decrement from loop.

if (weight3==0)
weight3=weight3-1;  //decrement reading parcel.

}

}

while (weight3!=0);

//clrscr();
system("cls");

do
{
menu();
gotoxy(15,22);
cout<<"Enter your choice:";
cin>>choice;


switch(choice)
{
  case 1: load_flight1();
	break;
  case 2: load_flight2();
	break;
  case 3: load_flight3();
	break;
  case 4: generate_report();
	break;
  case 5: exit();
  	break;
  default: cout<<"Invalid menu choice"<

Check the video on how this works on YouTube here:
http://youtu.be/8oXLDWZAd-g

Comments

Popular posts from this blog

Working with Dropdownbox elements in Selenium WebDriver

How to select element from a Dropbox We are going to use Selenium webDriver and chrome driver to test this. In addition, this test was created on Mac.  I assume you have installed and setup java in your system path.  Also, install Eclipse for jee. 1. First let's take a look at a quick test case: Test case: TC_1. Register on http://automationpractice.com/index.php TC_1.1: Launch hope page -http://automationpractice.com/index.php TC_1.2 : Click on link ‘Sign in’ TC_1.3 : Under “Create Account” subheading, enter Email address in ‘Email address’ textfield TC_1.4 : Click on ‘Create an account’ button. —————————————————————————————— Test data: Email address: gorgeous12@hotmail.com http://automationpractice.com/index.php ---------------------------------------------------------------- Expected : http://automationpractice.com/index.php?controller=my-account ———————————------------ 2. Next, create a maven project in Eclipse 3....

Date Picker 2 -Calendar

Working on date picking- part 2 package com.phpTravels.PHPTravels; import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; public class LaunchClose { WebDriver driver ; @BeforeClass public void launchApp() { //instantiate Chrome Browser driver System.setProperty( "webdriver.chrome.driver" , "/Users/tester/Documents/webDrivers/chrome/chromedriver" ); driver = new ChromeDriver(); driver .get( "https://www.phptravels.net/" ); //boolean applaunch =driver.getCurrentUrl(); System. out .println( "browser has launched" ); } @AfterClass public void CloseApp() { driver .quit(); System. out .println( "browser has quite" ); } } Second class - package com.phpTravels.PHPTravels; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.D...

Cypress UI Automation - part 1

Java to Cypress-JavaScript Automation Migration Introduction: Across Cancer Research UK engineering department, we currently use a Java automation framework for our User interface and API testing. The framework has evolved in the last 3 to 4 years and currently, we have 19 products/project, (running approximately 1350 test scenarios) using the framework to run the respective sanity/regression packs. The project/products extend across different technology stacks such as Drupal, Symphony, React JS, .Net, OBI and Siebel CRM.   The Quality Assurance (QA) test team are currently under the process to be transformed into a fully-fledged Quality Assurance function.   As part of this transformation, we would like to have a comprehensive, automated test suite that can be maintained by developers and testers. Furthermore, our front-end web development is moving into JavaScript, now is the right time to migrate our automation framework also from java into JavaScript. The introduction ...