Experimental Bill Calculator using Class in CPP

 // Online C++ compiler to run C++ program online

#include <iostream>

#include<stdio.h>


#include<stdlib.h>

using namespace std;

class bill{

  public:

  int units;

  void billCalci(){

      cout<<"The units for this object of class bill is "<<units;cout<<endl;

      cout<<"The total charge for your units is:- ";

      cout<<((units<0)?:(units<=100)?units*2:(units>=101 && units<=200)?units*4:(units>200)?units*7:-1);


  }

};

int main() {

    // Write C++ code here

    std::cout << "Hello world!";

int choice,check=0;

bill obj[3];

cout<<"\nEnter 1 for entry of units,2 for seeing the total charge of any customer,3 for exiting the program.\n";

hi:

cout<<"Enter your choice.\n";

cin>>choice;

if(choice==3){

    return 0;

}

if(choice==1){

    cout<<"Enter the units for the respective customers.\n";check++;

    for(int i=0;i<3;i++){

        cout<<"Enter the units for the customer no. "<<i+1<<" ";

        cin>>obj[i].units;

    }

}

if(choice==2){

    if(check==0){

        cout<<"Don't Gooof around boooy.\n";

    goto hi;

        

    }

    // for(int i=0;i<3;i++){

        cout<<"Enter the customer no. whose total charge you want to see\n";

        int choice;

        cin>>choice;

        obj[choice].billCalci();

    // }

   

}

goto hi;

    return 0;

}

Comments

Popular Posts