Help me please!!

0 Xhengis Miftari · April 1, 2015
please help me with this program
Write a C++ program for a college’s admissions office. Prompt the user for a student’s numeric high school grade point average (for example, 3.2) and an admission test score from 0 to 100. Print the message “Accept” if the student has any of the following: A grade point average of 3.0 or above and an admission test score of at least 60 A grade point average below 3.0 and an admission test score of at least 80 If the student does not meet either of the qualification criteria, print “Reject”.

Post a Reply

Replies

- page 1
Oldest  Newest  Rating
+1 zhang yida · May 3, 2015
it's very easy ,why dont you try to figure it out with Google by yourself,I think you will learn it better.
0 Xhengis Miftari · May 2, 2015
very understandable.thank you again for your help.
i am happy that a person like you exiist
0 Franz Schmidt · May 2, 2015
No problem, this forum is made just for this reason :D

to your question:
basically there are 2 types of variables (don't mix up with data types that's something different):
- global variables
- local variables

If i use a global variable i declair it outside of the main, what means i can use it in any funtion i want.
If i use local variables i would need to declair the two variables in main, what means i would need to pass on the variables as parameters in any function i need these values.
And the "= 0" is something i got used to, because in this case it is unnecessary, but whenever you use something like:
Area += 8*10; 
or something like this you get into trouble when you didn't initialize Area to 0, because there could be any number inside Area and the addition would be something unexpectedly.

And the display function is just a peace of code, which runs when gets called, without return value. it just displays the values in your console window.
And if i would use local variables i would need to pass on the variables Area and Perimeter to this function so i can execute the values.


Hope it was understandable :D
0 Xhengis Miftari · May 2, 2015
thank you very very very much for your help
if you have time to explain me with simple words.
i dont undersand only two parts you have done 
why you had declare double Area=0 so what does it mean when we do =0 and  display()
thank you
0 Franz Schmidt · May 2, 2015
You have really nice starting points with your function.

But you have some little mistakes. If you return a value from a function you don't need to pass a parameter to the function for this variable. You need to declair the Area and the Perimeter variable inside your function and not as a parameter of the function. 

And when you call a function inside the main you don't need to write the return type before the function name and for the parameter variables you need to pass on real values and not undefined variables.
And if you have a return type of a function you need to asign the return value to a variable:
double Area = calculateArea(3, 4);

Don't worry, skill comes with practice, those are only some beginners mistakes.


I made your program like this: http://txt.do/xbe0

I don't know how far you learnd C++ but if you really want to do real C++ you should learn how to code in an object oriented way with classes and stuff.
Here is the whole code in OOP: http://txt.do/xbet
0 Xhengis Miftari · May 2, 2015
i have this exercise i have done most of it but i dont know to continue.could anyone help me?
Write a C++ program using functions to calculate the area and perimeter of a rectangle.
The program should meet the following requirements: [14 points]
a. Accept input from the user for length and width, both of which are of type double.
b. Create a value-returning function named calculateArea that takes two parameters,
namely the length and the width of the rectangle, which are of type double. This
function should return a double value. Formula: Area=Length x Width
c. Create a value-returning function named calculatePerimeter that takes two
parameters, namely the length and the width of the rectangle, which are of type
double. This function should return a double value. Perimeter=2 x (Length + Width)
d. Create a void function named display that displays the area and the perimeter of the

my code:
#include<iostream>
using namespace std;

double calculateArea(double length, double width,double Area)
{
cin>>length>>width;
Area=length*width;
return Area;
}
double calculatePerimeter(double length, double width,double Perimeter)
{
cin>>length>>width;
Perimeter=2*(length+width);
return Perimeter;
}


int main()
    {

double calculateArea(double length, double width, double Area);
    double calculatePerimeter(double length, double width, double Perimeter);
cout<<"Enter length and width : "<<endl;
return 0;
  }
0 Xhengis Miftari · May 2, 2015
thank you man for your help even though i managed to do it by my self and now after many days when i saw you i was heppay that someone tried to help me
0 Franz Schmidt · April 10, 2015
So here you go:

#include <iostream>
using namespace std;

float add(float num1, float num2){
return num1 + num2;
}
void print_total(int *item, float sum){
cout << endl << endl << "Products bought:" << endl;
for (int n = 0; n < 3; n++){
switch (item[n]){
case 1:
cout << "cheseburger - $4.99" << endl;
break;
case 2:
cout << "pepsi - $2.00" << endl;
break;
case 3:
cout << "chips - $0.75" << endl;
break;
}
}
cout << endl << "total: $" << sum;
}
int main(){
int product;
int item[3];
float sum = 0.0;
bool exit_flag = false;
for (int i = 0; i < 3; i++){
cout << endl <<"Choose your product: " << endl;
cout << "1. cheseburger - $4.99" << endl;
cout << "2. pepsi - $2.00" << endl;
cout << "3. chips - $0.75" << endl;
cout << "0 to quit" << endl;
cout << "subtotal: $" << sum << endl;
cout << "Your choose: ";

cin >> product;
item = product;
switch (product){
case 0:
exit_flag = true;
break;
case 1:
sum = add(sum, 4.99);
break;
case 2:
sum = add(sum, 2.0);
break;
case 3:
sum = add(sum, 0.75);
break;
}
if (exit_flag){
break;
}
}
print_total(item, sum);
return 0;
}

just ask what you don't understand or what you haven't learnd jet and i'll explain it to you.:D


EDIT: Sorry but codetags still don't work properly so here you are: http://textuploader.com/xgkt
0 Xhengis Miftari · April 10, 2015
can anyone help me with this exercise plz i have an exam tomorrow and a similiar exercise like this one will be on the exam .plz help me solve it 
0 Xhengis Miftari · April 6, 2015
hello!!
now i have done the most ecerxise but i have stuck at these point
the xercise-----Write an application that displays a menu of three items in a restaurant as follows:
1. Cheeseburger 4.99
2. Pepsi 2.00
3. Chips 0.75
Prompt the user to choose an item using the number (1, 2, or 3) that corresponds to the item, or to enter 0 to quit the application. After the user makes the first selection, if the choice is 0, display a bill of $0. Otherwise, display the menu again. The user should respond to this prompt with another item number to order or 0 to quit. If the user types 0, display the cost of the single requested item. If the user types 1, 2, or 3, add the cost of the second item to the first, and then display the menu a third time. If the user types 0 to quit, display the total cost of the two items; otherwise, display the total for all three

My code
#include<iostream>
using namespace std;
int main ()
{
int product, item1, item2, item3;
cout<<"Chose a product: "<<endl;
cout<<"1 for cheseburger"<<endl;
cout<<"2 for pepsi"<<endl;
cout<<"3 for chips"<<endl;
cout<<"0 to quit"<<endl;
cin>>product;
switch(product)
{

case 0:




case 1:
cout<<"The price is 4.99"<<endl;
cout<<"Chose a product: "<<endl;
cout<<"1 for cheseburger"<<endl;
cout<<"2 for pepsi"<<endl;
cout<<"3 for chips"<<endl;
cout<<"0 to quit"<<endl;
break;


case 2:
cout<<"The price is 2.00"<<endl;
cout<<"1 for cheseburger"<<endl;
cout<<"Chose a product: "<<endl;
cout<<"2 for pepsi"<<endl;
cout<<"3 for chips"<<endl;
cout<<"0 to quit"<<endl;
break;


case 3:
cout<<"The price is 0.75"<<endl;
cout<<"Chose a product: "<<endl;
cout<<"1 for cheseburger"<<endl;
cout<<"2 for pepsi"<<endl;
cout<<"3 for chips"<<endl;
cout<<"0 to quit"<<endl;
break;



}


}
  • 1
  • 2

C++

106,949 followers
About

Used in many types of software including music players, video games, and many large scale applications.

Links
Moderators
Bucky Roberts Administrator