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 2
Oldest  Newest  Rating
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 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 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
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
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
very understandable.thank you again for your help.
i am happy that a person like you exiist
+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.
  • 1
  • 2

C++

126,379 followers
About

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

Links
Moderators
Bucky Roberts Administrator