If you are having any problem regarding the output or evaluation in Elab, Then check your code here.
Table of Contents
Table of Content
[CODE SOURCE : GOOGLE]
DATE CLASS
using namespace std;
class Date{
int day,month,year;
public:
Date(){
cin >> day >> month >> year;
}
void getDate(){
switch(month){
case 1: cout << "January ";
break;
case 2: cout << "February ";
break;
case 3: cout << "March ";
break;
case 4: cout << "April ";
break;
case 5: cout << "May ";
break;
case 6: cout << "June ";
break;
case 7: cout << "July ";
break;
case 8: cout << "August ";
break;
case 9: cout << "September ";
break;
case 10: cout << "October ";
break;
case 11: cout << "November ";
break;
case 12: cout << "December ";
break;
}
cout << day << " " << year;
}
};
int main() {
Date D;
D.getDate();
return 0;
}
Use the code: Miru2021
Online Shopping
using namespace std;
class item{
public:
int items;
int itemCode[20];
float price[20];
void initialize(){
cin >> items;
int i;
for(i=0;i<items;i++){
cin >> itemCode[i] >> price[i];
}
}
float largest(){
int i,largest=price[0];
for(i=1;i<items;i++){
if(price[i]>largest)
largest = price[i];
}
return largest;
}
float sum(){
float sum=0;
int i;
for(i=0;i<items;i++){
sum+=price[i];
}
return sum;
}
void displayitems(){
cout << "Code and Price" << endl;
int i;
for(i=0;i<items;i++){
cout << itemCode[i] << " and " << price[i] << endl;
}
}
};
int main(){
item I;
I.initialize();
cout << "Largest Price=" << I.largest() << endl;
cout << "Sum of Prices=" << I.sum() << endl;
I.displayitems();
return 0;
}
Click ont the image to know more !
Student Details
#include<iostream>
using namespace std;
#include
class student
{
private:
int roll;
string name;
float height;
float weight;
public:
student()
{
name="Nikhil";
roll=20;
height=165.5;
weight=58.2;
}
void read()
{
cin>>name>>roll>>height>>weight;
}
void display()
{
cout<<name<<" "<<roll<<" "<<height<<" "<<weight<<endl;
}
};
int main() {
student s1,s2;
s1.read();
s1.display();
s2.display();
return 0;
}
Find your Partner
using namespace std;
class partner{
string num;
string arr[8][2] = {{"3", "6UB"},{"6", "3UB"},{"2", "5MB"},{"5", "2MB"},{"1", "4LB"},{"4", "1LB"},{"7", "8SU"},{"8", "7SL"}};
public:
partner(string num){
this->num = num;
}
void findpartner(){
for(int i=0; i<8; i++){
if(num == arr[i][0]){
cout << arr[i][1] << endl;
break;
}
}
}
};
int main() {
int n;
string num;
cin >> n;
for(int i=0; i<n; i++){
cin >> num;
partner objname(num);
objname.findpartner();
}
return 0;
}
Use the code : Miru2021
Inner and Outer
#include <iostream>
using namespace std;
class outer
{
public:
int x;
void get()
{
cin>>x;
}
class inner
{
private:
int y;
public:
void get()
{
cin>>y;
}
void sum()
{
outer k;
k.get();
cout<<k.x+y;
}
};
};
main()
{
outer::inner b;
b.get();
b.sum();
}
Cricbuzz Library
#include<iostream>
using namespace std;
class Cricket
{public:
string playername;
int jerseynum;
int no_of_innings;
int counter;
Cricket(int n,string c,int no)
{
jerseynum=n;
no_of_innings=no;
playername=c;
}
void show()
{
cout<<"Jersey Num:"<<jerseynum<<endl;
cout<<"Name of the Player:"<<playername<<endl;
cout<<"No of Innings Played:"<<no_of_innings<<endl;
}
void count()
{
cout<<counter;
}
};
int main(
) {
int a,b,h,d;
string e,f;
cin>>a>>e>>b;
cin>>h>>f>>d;
Cricket lib1(a,e,b);
Cricket lib2=Cricket(h,f,d);
lib1.show();
lib2.show();
return 0;
}
Arulmozhivarman and his pets
#include<iostream>
using namespace std;
class catanddog
{public:
int c,d,l,t;
void count()
{
cin>>t;
while(t–){
cin>>c>>d>>l;
long int u=l-4*d;
if(u<0||(u%4!=0)||u>4*c)
cout<<"no";
else cout<<"yes";
cout<<endl;
}
}
};
int main()
{
catanddog obj;
obj.count();
return 0;
}
Click here Amazon Best selling product
Code: Miru2021
TRAI
using namespace std;
class Phone{
public:
int stdCode,exchangeCode,phoneNumber;
void change(){
char inputNumber[13];
cin >> inputNumber;
int test[13],i;
for(i=0;i<13;i++){
test[i] = inputNumber[i];
test[i]-=48;
}
for(i=0;i<3;i++){
if(test[i]==0) test[i]=91;
cout << test[i];
}
for(i=3;i<13;i++){
cout << inputNumber[i];
}
}
};
int main(){
Phone obj;
obj.change();
return 0;
}
Pamban Bridge
using namespace std;
class tollbooth{
public:
int carsPassed;
float tollCollected;
tollbooth(){
carsPassed=0;
tollCollected=0;
}
void payingcar(double pay){
carsPassed++;
tollCollected+=pay;
}
void nonpayingcar(){
carsPassed++;
}
void display(){
cout << "Total number of cars passed = " << carsPassed << endl;
cout << "Total amount collected = " << tollCollected << endl;
}
};
int main() {
tollbooth obj;
char vehicleNumber[10];
float payAmount;
int carsPassed,i;
cin >> carsPassed;
for(i=0;i<carsPassed;i++){
cin >> vehicleNumber >> payAmount;
if(payAmount>0) obj.payingcar(payAmount);
else obj.nonpayingcar();
}
obj.display();
return 0;
}
Click on the image to know more!
Athithya Karihalan and his Hobby
#include <math.h>
using namespace std;
class Building
{
private:
int length, width, ratePerSqFeet;
public:
void initializeData(int l, int w, int r)
{
length=l;
width=w;
ratePerSqFeet=r;
}
void getLength(int length, int width, int ratePerSqFeet)
{
cout<<"Length : "<<length<<endl;
}
void getWidth()
{
cout<<"Width : "<<width<<endl;
}
void getRatePerSqFeet()
{
cout<<"Rate Per SqFt : "<<ratePerSqFeet<<endl;
}
void calculateCost()
{
int z;
z=length*width*ratePerSqFeet;
cout<<"Cost of the Building : "<<z<<endl;
}
void determineSuitability()
{
if(length==70)
{
if(abs(length-width)>10)
cout<<"Suitability : Suitable";
}
else if(length==width)
cout<<"Suitability : Suitable";
else if(abs(length-width)<10)
{
cout<<"Suitability : Suitable"<<endl;
}
else
{
cout<<"Suitability : Not Suitable"<<endl;
}
}
}objname;
int main()
{
int l, w, r;
cin>>l>>w>>r;
objname.initializeData(l, w, r);
objname.getLength(l, w, r);
objname.getWidth();
objname.getRatePerSqFeet();
objname.calculateCost();
objname.determineSuitability();
return 0;
}
Use the code : Miru2021
Land Survey
#include<iostream>
using namespace std;
class room{int l,b,h;public :void getroom()
{cin>>l>>b>>h;}
void putroom()
{cout<<"Length="<<l;
cout<<endl;
cout<<"Breadth="<<b;
cout<<endl;
cout<<"Height="<<h;
cout<<endl;}};
class address {int hno;
char cty[30];
char state[30];
public :void getad()
{
cin>>hno;
cin>>cty;
cin>>state;
}
void putad()
{
cout<<"House No="<<hno;
cout<<endl;
cout<<"City="<<cty;
cout<<endl;
cout<<"State="<<state;
cout<<endl;}};
class house{char housename[30];
address a;
room r[10];
int n;
Click ont the image to know more !
public :void input();
void display();};
void house :: input()
{
cin>>housename;
cout<<"House name="<<housename<<endl;
a.getad();
a.putad();
cin>>n;
for(int i=0;i<n;i++)
{r[i].getroom();}}
void house :: display()
{for(int i=0;i<n;i++)
{cout<<"Details of Room "<<i+1<<"\n";
r[i].putroom();}}
int main()
{house x;
x.input();
x.display();
return 0;
}
Complex Game
using namespace std;
class Complex
{
public:
int r1,i1,r2,i2,r,i;
Complex()
{
cin>>r1>>i1>>r2>>i2;
}
void addcomplex()
{
r=r1+r2;
i=i1+i2;
}
void displaycomplex()
{
cout<<r1<<"+"<<i1<<"i";
cout<<"\n"<<r2<<"+"<<i2<<"i";
cout<<"\n"<<r<<"+"<<i<<"i";
}
};
int main() {
Complex obj;
obj.addcomplex();
obj.displaycomplex();
return 0;
}
Use the code: Miru2021
RBI
#include<string>
using namespace std;
class Bank{ private:
char name[50];
char accounttype[50];
int acc;
double balance;
public:
void initial()
{ std::cin>>name>>acc>>accounttype>>balance; }
void deposit()
{ float deposit;
cin>>deposit;
balance+=deposit; }
void withdraw() { float withdraw;
cin>>withdraw;
if(withdraw>balance){ cout<<"Insufficient amount\n";}
else balance-=withdraw; }
void disp() { cout<<"NAME="<<name<<"\nACCNO="<<acc<<"\nTYPE="<<accounttype<<"\nBALANCEAMOUNT="<<balance<<endl; }
};
int main(){float deposit,withdraw;
Bank obj;
obj.initial();
obj.deposit();
obj.withdraw();
obj.disp();
return 0;
}
Click ont the image to know more !
TNEB Billing
#include<iostream>
using namespace std;
class Electric
{
float unit;
char name[20];
public:
void accept()
{
cin>>name;
cin>>unit;
}
void print_bill();
};
void Electric::print_bill()
{
float bill=0.0;
if(unit>=0 && unit<=100)
bill=(500+(unit*0.40));
else if(unit>100 && unit<=300)
bill=(500+(100*0.40)+((unit-100)*0.50));
else if(unit>300)
bill=(500+(100*0.40)+(200*0.50)+((unit-300)*0.60));
if(bill>250)
bill=(bill+(bill*(15/100)));
cout<<"\nConsumer Name:"<<name;
cout<<"\nNumber of Consumers:"<<unit;
cout<<"\nBill to pay:"<<bill;
}
int main ()
{
Electric e[10];
int i,cnt;
cin>>cnt;
cout<<"\nNumber of Consumers:"<<cnt;
for(i=0;i<cnt;i++)
e[i].accept();
for(i=0;i<cnt; i++)
e[i].print_bill();
return 0;
}
Click here Amazon Best selling product
Code : Miru2021
Digital Library
#include<iostream>
#include <string.h>
using namespace std;
class library
{
public:
char name[20];
int roll;
int book_code;
static int counter;
library(char n[],int r,int no)
{
strcpy(name,n);
roll=r;
book_code=no;
}
void show()
{
cout<<"\nRoll No:"<<roll;
cout<<"\nName of the Student:"<<name;
cout<<"\nCode of Book Accessed:"<<book_code;
}
void count()
{
cout<<counter;
}
};
int main()
{
char name[20];
int rollno,code;
cin>>rollno>>name>>code;
library lib1(name,rollno,code);
cin>>rollno>>name>>code;
library lib2= library(name,rollno,code);
lib1.show();
lib2.show();
return 0;
}
Use the code: Miru2021
TNEB BILLING IS WRONG
PLS CHECK
THANK YOU FOR ALL HELP
Fixed