#include <cstdlib>
#include <iostream>
void high_Tenp(int [],int);
void low_Tenp(int []);
void Average_Tenp(int [],int);
using namespace std;
int main(int argc, char *argv[])
{
cout<<"\t\t***********************************"<<endl
<<"\t\t TEMPRATURE CALCULATION SYSTEM "<<endl
<<"\t\t***********************************"<<endl<<endl;
int n;
cout<<"Enter the number of consecutive days to read their temperature : ";
cin>>n;
int x[n];
int i, j, tmp;
for(i=0;i<n;i++)
{
cout<<endl<<"Enter temperature for day "<<i+1<<" : ";
cin>>x[i];
}
for(i=0; i<n; i++)
{
for(j=0; j<n-1; j++)
{
if (x[j] > x[j+1])
{
tmp = x[j];
x[j] = x[j+1];
x[j+1] = tmp;
}
}
}
Average_Tenp(x,n);
high_Tenp(x,n);
low_Tenp(x);
system("pause");
}
void high_Tenp(int a[],int arraysize)
{
cout<<"The Higest Temprature is : "<<a[arraysize-1]<<endl;
}
void low_Tenp(int a[])
{
int b=0;
cout<<"The Lowest Temprature is : "<<a[b]<<endl;
}
void Average_Tenp(int a[],int arraysize)
{
int i;
double c=0;
for ( i = 0 ; i < arraysize ; i ++)
{
c=c+a[i];
}
c=c/i;
cout<<endl<<"The Average Temprature is : "<<c<<endl;
}
void swap(int *x, int *y) //function using pointers to interchange the values
{
int tmp;
if(*x > *y)
{
tmp = *x;
*x = *y;
*y = tmp;
}
}
We tried that Assignment Solution, Graded Discussion Solution,Announcement
Search with our Site
Custom Search
Showing posts with label CS201. Show all posts
Showing posts with label CS201. Show all posts
Thursday, April 26, 2012
CS201 Asignment # 2 Solution 2012
Labels:
CS201
Friday, January 20, 2012
CS201 GDB Solution & Discussion Last Date: 24-01-2012
GDB will remain open for two consecutive working days from 23rd January to 24th January. Also make sure you post your GDB on time as No GDB will be accepted via email in any case.
Topic is as follows:
You have two classes, Class A and Class B. Being a programmer either you can implement Class B as nested class of Class A or you can inherit Class B from Class A.
These are two ways to describe the relationship between classes. Discuses the situations in which, concept of public inheritance and nested class is more appropriate to use. Justify with solid reasons.
Read more: CS201 GDB Solution & Discussion Last Date: 24-01-2012 - Virtual University of Pakistan http://vustudents.ning.com/group/cs201introductiontoprogramming/forum/topics/cs201-gdb-solution-discussion-last-date-24-01-2012#ixzz1k06mu2nh
Topic is as follows:
You have two classes, Class A and Class B. Being a programmer either you can implement Class B as nested class of Class A or you can inherit Class B from Class A.
These are two ways to describe the relationship between classes. Discuses the situations in which, concept of public inheritance and nested class is more appropriate to use. Justify with solid reasons.
Read more: CS201 GDB Solution & Discussion Last Date: 24-01-2012 - Virtual University of Pakistan http://vustudents.ning.com/group/cs201introductiontoprogramming/forum/topics/cs201-gdb-solution-discussion-last-date-24-01-2012#ixzz1k06mu2nh
Labels:
CS201
Assignment No. 05 Semester: Fall 2011 CS201 Discuss here
![]() | Assignment No. 05 Semester: Fall 2011 CS201: Introduction to Programming | Total Marks: 20 Due Date:26/01/2012 | |||||||||||||||||||||||||||||||
| Instructions: Please read the following instructions carefully before submitting assignment. It should be clear that your assignment will not get any credit if: § The assignment is submitted after due date. § The submitted assignment does not open or file is corrupt. § Assignment is copied(partial or full) from any source (websites, forums, students, etc) Note: You have to upload only .cpp file. Assignment in any other format (extension) will not be accepted and will be awarded with zero marks. For example, if you submit code in .doc (Word document) or .txt files, no reward will be given in any case. Objectives: The objective of this assignment is to provide hands on experience of: § Classes § Function Overloading § Dynamic Memory allocation in C/C++ § String Manipulation Functions § File Handling § Stream Manipulators Guidelines: § Code should be properly indented and well commented. § Follow C/C++ rules while writing variable names, function names etc § Use only dev-C++ for this assignment. § Use appropriate C/C++ structure i.e. if-else; switch statement etc to get inputs from user where required (Marks will be deducted if inappropriate structure will be used). | |||||||||||||||||||||||||||||||||
| | | ||||||||||||||||||||||||||||||||
| Problem Statement: Airline Fare System Write a program for air fare System which will calculate fare on already reserved ticket. Detailed Description: In the program, you are required to make a class with name 'airfare' and following are the data members of class airfare. ñ Seat type ñ Price ñ Tax ñ Airline charges In the main () function, create a constructor of class to initialize the class data members. Class must have a destructor. Create following user defined function as discussed below along with class constructors and destructor: GetData(), this function will take the input for seat type variable from the user and will set the ticket price according to the input taken from user. The function GetData() will prompt user to enter required information for seat type. Seat Type: User can select one of the Seat type: 1. First Class Seat 2. Business Class Seat 3. Economy Class Seat The function GetData() will also read the data from file named data.txt ( created in assignment no 3 ) to read the destination and then assigns the price for the given destination. Price: Price will be calculated on the basis of following information: 1- Fare type 2- Destination (Desire destination information will be read from the file “data.txt” ) The price will be assigned according to the table given below:
Airline charges: All airlines will charge 15% of ticket price extra to the all fare types along with the tax. Class should have a user-defined function named CalculateTax() to calculate the tax according to seat type and ticket price. Tax calculation will be done as below: If seat type is First class then tax will be 30% of ticket price If seat type is Business class then tax will be 20% of ticket price If seat type if Economy class then tax will be 10% of ticket price Calculateprice(), this member function will calculate price of already reserved ticket and will display total fare on the screen. Price calculation will add above calculated tax, airline charges to the actual ticket price according to following information. Fare = Airline Charges + Tax + Ticket Price In the function WriteData(), you are required to create a new text file name “fare.txt” in same folder/directory where you have saved your .cpp file. Open this file by using file handling functions and then write all air fare information in that file in following format. ------------------------------------------------------------------------ Name | Address| Date | Destination | Flight.No | Seat.No | Fare ------------------------------------------------------------------------. . . . . . . ------------------------------------------------------------------------ Required information of Name, Address, Date, Destination, Flight No, Seat No, should be taken from assignment no 3 output file. Points To Remember: Following points should be kept in mind and handled accordingly, otherwise marks will be deducted. ñ Reading and writing from text file, must be done with standard file handling functions provided in handouts. ñ All data members must be declared and initialized with appropriate data type. ñ Exceptional cases must be kept in mind and handled accordingly while taking input from user. ñ User must be prompted if there is any error while: ◦ Creating a file. ◦ Opening a file for reading/ writing. | |||||||||||||||||||||||||||||||||
Labels:
CS201
Thursday, January 12, 2012
CS201 Assignment No 4 Solution & Discussion
Assignment No. 04
Semester: Fall 2011
CS201: Introduction to Programming Total Marks: 20
Due Date:16/01/2012
Instructions:
Please read the following instructions carefully before submitting assignment. It should be clear that your assignment will not get any credit if:
The assignment is submitted after due date.
The submitted assignment does not open or file is corrupt.
Assignment is copied(partial or full) from any source (websites, forums, students, etc)
Note: You have to upload only .cpp file. Assignment in any other format (extension) will not be accepted and will be awarded with zero marks. For example, if you submit code in .doc (Word document) or .txt files, no reward will be given in any case.
Objectives:
The objective of this assignment is to provide hands on experience of:
Classes
Member Functions
Dynamic Memory allocation in C/C++
String Manipulation Functions
File Handling
Guidelines:
Code should be properly indented and well commented.
Follow C/C++ rules while writing variable names, function names etc
Use only dev-C++ for this assignment.
Use appropriate C/C++ structure i.e. if-else; switch statement etc to get inputs from user where required (Marks will be deducted if inappropriate structure will be used).
Problem Statement: Airline Schedule System
Write a program for Flight Schedule System which will check the flight schedule.
Detailed Description:
In the program, you are required to make a class with name 'Schedule' and following are the data members of class schedule.
Trip
Date of departure
Date of return
Destination(Going to)
Origin (Leaving from)
Flight No
Departure time
Arrival time
Initialize all these data members with their default values by creating constructor for the class. Object creation of class should be done dynamically using dynamic memory allocation functions. Also class schedule should have a destructor.
Along with constructor and destructor of class, it is mandatory to used getter and setter functions for all above stated data members to properly assign their values.
Detail description of all data members are given below.
Class data members description:
Trip:
Class variables; trip should be off type Boolean; value of the variable should be taken from the user, if user sets it to true, then user should enter the required information for following data members and this trip will become a Round Trip:
Date of departure
Date of return
Destination
Origin
And if user set the variable values to false, prompt user to enter the required information for one-way trip:
Date of departure
Destination
Origin
Date of departure/Date of return:
Date of departure and date of return can be any date, entered by the user.
Flight No:
Flight numbers will be assigned randomly which can be any number from 0 to 200.
Origins/Destinations:
The user can chose one of five destinations and origins:
Lahore
Karachi
Islamabad
Peshawar
Quetta
Departure Time and Arrival Time
Both these will be generated randomly and must have at least difference of two hours in-between departure time and arrival time.
When you are done with this, you are required to write a member function of class named WriteData().In the function WriteData(), you are required to create a new text file name “schedule.txt” in same folder/directory where you have saved your .cpp file. Open this file by using file handling functions and then write allSchedule information in that file in following format:
Flight No:
Origin:
Destination:
Date of Departure:
Date of Return:
Departure Time:
Arrival Time:
Points To Remember:
Following points should be kept in mind and handled accordingly, otherwise marks will be deducted.
Reading and writing from text file, must be done with standard file handling functions provided in handouts.
All data members must be declared and initialized with appropriate data type.
Exceptional cases must be kept in mind and handled accordingly while taking input from user.
User must be prompted if there is any error while:
◦ Creating a file.
◦ Opening a file for reading/ writing.
Read more: CS201 Assignment No 4 Solution & Discussion Due Date:16-01-2012 - Virtual University of Pakistan http://vustudents.ning.com/group/cs201introductiontoprogramming/forum/topics/cs201-assignment-no-4-solution-discussion-due-date-16-01-2012#ixzz1jEpmyBfn
Semester: Fall 2011
CS201: Introduction to Programming Total Marks: 20
Due Date:16/01/2012
Instructions:
Please read the following instructions carefully before submitting assignment. It should be clear that your assignment will not get any credit if:
The assignment is submitted after due date.
The submitted assignment does not open or file is corrupt.
Assignment is copied(partial or full) from any source (websites, forums, students, etc)
Note: You have to upload only .cpp file. Assignment in any other format (extension) will not be accepted and will be awarded with zero marks. For example, if you submit code in .doc (Word document) or .txt files, no reward will be given in any case.
Objectives:
The objective of this assignment is to provide hands on experience of:
Classes
Member Functions
Dynamic Memory allocation in C/C++
String Manipulation Functions
File Handling
Guidelines:
Code should be properly indented and well commented.
Follow C/C++ rules while writing variable names, function names etc
Use only dev-C++ for this assignment.
Use appropriate C/C++ structure i.e. if-else; switch statement etc to get inputs from user where required (Marks will be deducted if inappropriate structure will be used).
Problem Statement: Airline Schedule System
Write a program for Flight Schedule System which will check the flight schedule.
Detailed Description:
In the program, you are required to make a class with name 'Schedule' and following are the data members of class schedule.
Trip
Date of departure
Date of return
Destination(Going to)
Origin (Leaving from)
Flight No
Departure time
Arrival time
Initialize all these data members with their default values by creating constructor for the class. Object creation of class should be done dynamically using dynamic memory allocation functions. Also class schedule should have a destructor.
Along with constructor and destructor of class, it is mandatory to used getter and setter functions for all above stated data members to properly assign their values.
Detail description of all data members are given below.
Class data members description:
Trip:
Class variables; trip should be off type Boolean; value of the variable should be taken from the user, if user sets it to true, then user should enter the required information for following data members and this trip will become a Round Trip:
Date of departure
Date of return
Destination
Origin
And if user set the variable values to false, prompt user to enter the required information for one-way trip:
Date of departure
Destination
Origin
Date of departure/Date of return:
Date of departure and date of return can be any date, entered by the user.
Flight No:
Flight numbers will be assigned randomly which can be any number from 0 to 200.
Origins/Destinations:
The user can chose one of five destinations and origins:
Lahore
Karachi
Islamabad
Peshawar
Quetta
Departure Time and Arrival Time
Both these will be generated randomly and must have at least difference of two hours in-between departure time and arrival time.
When you are done with this, you are required to write a member function of class named WriteData().In the function WriteData(), you are required to create a new text file name “schedule.txt” in same folder/directory where you have saved your .cpp file. Open this file by using file handling functions and then write allSchedule information in that file in following format:
Flight No:
Origin:
Destination:
Date of Departure:
Date of Return:
Departure Time:
Arrival Time:
Points To Remember:
Following points should be kept in mind and handled accordingly, otherwise marks will be deducted.
Reading and writing from text file, must be done with standard file handling functions provided in handouts.
All data members must be declared and initialized with appropriate data type.
Exceptional cases must be kept in mind and handled accordingly while taking input from user.
User must be prompted if there is any error while:
◦ Creating a file.
◦ Opening a file for reading/ writing.
Read more: CS201 Assignment No 4 Solution & Discussion Due Date:16-01-2012 - Virtual University of Pakistan http://vustudents.ning.com/group/cs201introductiontoprogramming/forum/topics/cs201-assignment-no-4-solution-discussion-due-date-16-01-2012#ixzz1jEpmyBfn
Labels:
CS201
Subscribe to:
Posts (Atom)
