Student Needing Help! C++

Discussion in 'Programming' started by scottlpool2003, Oct 10, 2008.

  1. #1
    Hi guys

    I only started programming a few weeks back so forgive my noobishness but I'm studying for a degree in IT.

    This assignment is for calculating call costs, durations, discounts etc etc etc.

    Here's the coding so far...

    //A program by Scott Brade to calculate call costs.
    //10/10/08
    
    #include <iostream.h>
    #include<stdio.h>
    
    double mins,totmins,fullcost,actualcost,discount,day1;
    char day;
    
    
    
    void parking()
    
    {
    {
    cout<<"+----------------------------+\n";
    cout<<"|          M = Monday        |\n";
    cout<<"|          T = Tuesday       |\n";
    cout<<"|          W = Wednesday     |\n";
    cout<<"|          U = Thursday      |\n";
    cout<<"|          F = Friday        |\n";
    cout<<"|          A = Saturday      |\n";
    cout<<"|          S = Sunday        |\n";
    cout<<"+----------------------------+\n\n";
    }
    cout<<"Enter minutes\n\n";
    cin>>totmins;
    cout<<"What day is it?\n\n";
    cin>>day;
    cin>>day1;
    
    	if(totmins<30)
    
    	{
    		fullcost=1.25;
    	}
    
    	else if(totmins>=30)
    
    	{
    		fullcost=(((totmins-30)*.20)+1.25);
    	}
    }
    
    void discounts()
    
    {
    	if ((day == 'M')||(day == 'T'))
    
    	{
    		discount=0.6;
    	}
    
    	else
    	{
    		discount=0.3;
    	}
    
    	cout<<endl;
    	cout<<endl;
    	cout<<endl;
    	cout<<"Your parking cost is on "<<day1 <<fullcost;
    	cout<<endl;
    	discount=(fullcost*discount);
    	cout<<"Discount "<<discount;
    	cout<<endl;
    
    	//actualcost=()
    
    }
    
    void main()
    
    {
    	parking();
    
    	discounts();
    
    }
    PHP:
    I'm trying to use the input "Please enter day" as both a variable & function so the user doesn't need to input the day twice. Is this possible as it doesn't work at the moment.

    cout<<"What day is it?\n\n";
    cin>>day;
    cin>>day1;
    PHP:
     
    scottlpool2003, Oct 10, 2008 IP
  2. estetique69

    estetique69 Peon

    Messages:
    41
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    cin>>day;
    cin>>day1;
    PHP:
    Why your requesting more than 1 cin without an additional output for user ?
    I will enter day1, but app will wait for another ..

    Next thing, function is not the same as variable !
    you create a cin containing function for example .. GetUserInput, and after that use your day1 or any other variables :cool:
     
    estetique69, Oct 10, 2008 IP
  3. it career

    it career Notable Member

    Messages:
    3,562
    Likes Received:
    155
    Best Answers:
    0
    Trophy Points:
    270
    #3
    Try cout<<"What day is it? <<endl; cin>>day>>day;
     
    it career, Oct 11, 2008 IP
  4. marco786

    marco786 Banned

    Messages:
    42
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #4
    cin>>xyz;
    cout<<xyz<<"is the value "<<endl;
    endl should be used for next line instead of what u use.
    you used some of the c language conventions....

    You can contact me or PM for any assistant in C++, Java, Oracle, SQL, PL-SQL, Mysql.....
    Thank yOU.
     
    marco786, Oct 11, 2008 IP