0% found this document useful (0 votes)
30 views15 pages

Lab Report 1

This document is a lab report submitted by student Shahed Annam containing solutions to 12 problems from Chapter 2 in Object Oriented Programming. The report includes the student and instructor details, problem statements for each question, and the C++ code submitted as solutions. Each problem solution is presented on its own page with page numbers running from 1 to 14.

Uploaded by

Shahed Annam
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
0% found this document useful (0 votes)
30 views15 pages

Lab Report 1

This document is a lab report submitted by student Shahed Annam containing solutions to 12 problems from Chapter 2 in Object Oriented Programming. The report includes the student and instructor details, problem statements for each question, and the C++ code submitted as solutions. Each problem solution is presented on its own page with page numbers running from 1 to 14.

Uploaded by

Shahed Annam
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 15

Lab report 01

Title: Chapter 2 Problems

Course title: Object Oriented Programming


Course code: CSE-160
1 Year 2nd Semester Examination 2021
st

Date of Submission: 09/10/2022

Submitted to-

Dr. MD. Ezharul Islam


Associate Professor
Department of Computer Science and Engineering
Jahangirnagar University
Savar, Dhaka-1342

Sl Class Roll Exam Roll Name

01 381 210901 Shahed Annam

Department of Computer Science and Engineering


Jahangirnagar University
Savar, Dhaka, Bangladesh
Page |1

Problem Number: 1

#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
cout<<"Enter a number of gallons"<<endl;
cin>>n;
cout<<(float)n/7.481<<endl;
}
Page |2

Problem Number: 2

#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
cout<<"1990"<<setw(10)<<"135"<<endl;
cout<<"1991"<<setw(10)<<"7290"<<endl;
cout<<"1992"<<setw(10)<<"11300"<<endl;
cout<<"1993"<<setw(10)<<"16200"<<endl;

return 0;
}
Page |3

Problem Number: 3

#include<bits/stdc++.h>
using namespace std;
int main()
{
int n=10;
cout<<n<<endl;
n+=10;
cout<<n<<endl;
n--;
cout<<n<<endl;

return 0;
}
Page |4

Problem Number: 4

#include<bits/stdc++.h>
using namespace std;
int main()
{
cout<<"Candy is dandy,"<<endl;
cout<<"But liquor is quicker.";

return 0;
}
Page |5

Problem Number: 5

#include<iostream>
#include<CTYPE.H>
using namespace std;
int main()
{
char x;
cout<<"enter a letter"<<endl;
cin>>x;
cout<<islower(x)<<endl;

return 0;
}
Page |6

Problem Number: 6

#include<bits/stdc++.h>
using namespace std;
int main()
{
float n;
cout<<"Enter an amount in dollars"<<endl;
cin>>n;
cout<<"In British pound "<<n/1.487<<endl;
cout<<"In French franc "<<n/0.172<<endl;
cout<<"In German deutschemark "<<n/0.584<<endl;
cout<<"In Japanese yen "<<n/0.00955<<endl;

return 0;
}
Page |7

Problem Number: 7

#include<bits/stdc++.h>
using namespace std;
int main()
{
float n;
cout<<"Enter temparature in Celsius"<<endl;
cin>>n;
cout<<"In Farenhite "<<((n*9)/5)+32<<endl;

return 0;
}
Page |8

Problem Number: 8

#include<bits/stdc++.h>
using namespace std;
int main()
{
cout<<"Portcity "<<setfill('.')<<setw(20)<<"2425785"<<endl;
cout<<"Dhaka "<<setfill('.')<<setw(20)<<"563255626"<<endl;
cout<<"Dinajpur "<<setfill('.')<<setw(20)<<"45236"<<endl;
cout<<"Chittogong"<<setfill('.')<<setw(20)<<"1234"<<endl;
cout<<"Sylhet "<<setfill('.')<<setw(20)<<"789624"<<endl;

return 0;
}
Page |9

Problem Number: 9

#include<bits/stdc++.h>
using namespace std;
int main()
{
int a,b,c,d;
char ch;
cin>>a>>ch>>b;
cin>>c>>ch>>d;
cout<<a*d+b*c<<"/"<<b*d<<endl;

return 0;
}
P a g e | 10

Problem Number: 10

#include<bits/stdc++.h>
using namespace std;
int main()
{
float pound,shillings,pence,decimal;
cout<<"Enter pounds: ";
cin>>pound;
cout<<"Enter shillings: ";
cin>>shillings;
cout<<"Enter pence: ";
cin>>pence;
decimal = pound + ((pence/12)+shillings)/20;
cout<<"Decimal pounds = "<<fixed<<setprecision(2)<<decimal;

return 0;
}
P a g e | 11

Problem Number: 11

#include<bits/stdc++.h>
using namespace std;
int main()
{
cout<<setiosflags(ios::left)<<setw(20)<<"Last name";
cout<<setiosflags(ios::left)<<setw(20)<<"First name";
cout<<setiosflags(ios::left)<<setw(20)<<"Street address";
cout<<setiosflags(ios::left)<<setw(20)<<"Town";
cout<<setiosflags(ios::left)<<setw(20)<<"State"<<endl;

cout<<"-----------------------------";
cout<<"-----------------------------";
cout<<"----------------------------"<<endl;

cout<<setiosflags(ios::left)<<setw(20)<<"Jones";
cout<<setiosflags(ios::left)<<setw(20)<<"Bernard";
cout<<setiosflags(ios::left)<<setw(20)<<"109 Pine Lane";
cout<<setiosflags(ios::left)<<setw(20)<<"Littletown";
cout<<setiosflags(ios::left)<<setw(20)<<"MI"<<endl;

cout<<setiosflags(ios::left)<<setw(20)<<"O’Brian";
cout<<setiosflags(ios::left)<<setw(20)<<"Coleen";
cout<<setiosflags(ios::left)<<setw(20)<<"42 E. 99th Ave.";
cout<<setiosflags(ios::left)<<setw(20)<<"Bigcity";
cout<<setiosflags(ios::left)<<setw(20)<<"NY"<<endl;
P a g e | 12

cout<<setiosflags(ios::left)<<setw(20)<<"Wong";
cout<<setiosflags(ios::left)<<setw(20)<<"Harry";
cout<<setiosflags(ios::left)<<setw(20)<<"121-A Alabama St.";
cout<<setiosflags(ios::left)<<setw(20)<<"Lakeville";
cout<<setiosflags(ios::left)<<setw(20)<<"IL";

return 0;
}
P a g e | 13

Problem Number: 12

#include<bits/stdc++.h>
using namespace std;
int main()
{
float n,x,y;
int a,b,c;
cout<<"Enter decimal pounds: ";
cin>>n;
a=n;
x=n-a;
x*=20;
b=x;
y=x-b;
y*=12;
c=y;
cout<<a<<"."<<b<<"."<<c<<endl;

return 0;
}
P a g e | 14

You might also like