Thread: I could use some help please

  1. #1
    Registered User
    Join Date
    Dec 2018
    Posts
    3

    I could use some help please

    Hi. I'm working on a project and i have most of it done. but I'm having some issues with the program. the biggest problems I'm having is that it isn't prompting the user to type in the breakfast, lunch, and dinner price but it isn't and that my math is wrong (I've always had trouble with math XP) and i would appreciate the help.
    Attached Files Attached Files

  2. #2
    Programming Wraith GReaper's Avatar
    Join Date
    Apr 2009
    Location
    Greece
    Posts
    2,728
    I think you should tell us what is should be outputting that it isn't. I compiled and run it and it works "just fine", ignoring the warnings:
    Code:
    In function ‘int main()’:
    25:9: warning: unused variable ‘vechileExpense’ [-Wunused-variable]
      double vechileExpense;
             ^~~~~~~~~~~~~~
    32:9: warning: variable ‘mealTotal’ set but not used [-Wunused-but-set-variable]
      double mealTotal;
             ^~~~~~~~~
    33:9: warning: unused variable ‘total’ [-Wunused-variable]
      double total;
             ^~~~~
    37:9: warning: unused variable ‘nightlyRate’ [-Wunused-variable]
      double nightlyRate;
             ^~~~~~~~~~~
    49:6: warning: variable ‘d’ set but not used [-Wunused-but-set-variable]
      int d;
          ^
    50:9: warning: unused variable ‘parkingSpent’ [-Wunused-variable]
      double parkingSpent;
             ^~~~~~~~~~~~
    51:9: warning: variable ‘taxiSpent’ set but not used [-Wunused-but-set-variable]
      double taxiSpent;
             ^~~~~~~~~
    In function ‘void getParkingAmount(double&, double&)’:
    244:6: warning: unused variable ‘days’ [-Wunused-variable]
      int days;
          ^~~~
    242:51: warning: unused parameter ‘allowedParking’ [-Wunused-parameter]
     void getParkingAmount(double &parkingFee, double &allowedParking){
                                                       ^~~~~~~~~~~~~~
    In function ‘void getTaxiAmount(double&, double&)’:
    259:6: warning: unused variable ‘days’ [-Wunused-variable]
      int days;
          ^~~~
    257:46: warning: unused parameter ‘allowedTaxiFee’ [-Wunused-parameter]
     void getTaxiAmount (double &taxiFee, double &allowedTaxiFee){
                                                  ^~~~~~~~~~~~~~
    In function ‘void getHotelAmount(double&, double&)’:
    289:9: warning: variable ‘hotelFeeTotal’ set but not used [-Wunused-but-set-variable]
      double hotelFeeTotal;
             ^~~~~~~~~~~~~
    290:6: warning: unused variable ‘days’ [-Wunused-variable]
      int days;
          ^~~~
    287:46: warning: unused parameter ‘allowedHotelFee’ [-Wunused-parameter]
     void getHotelAmount(double &hotelFee,double &allowedHotelFee){
                                                  ^~~~~~~~~~~~~~~
    In function ‘void getMealAmount(double&, double&)’:
    309:6: warning: unused variable ‘day’ [-Wunused-variable]
      int day;
          ^~~
    314:9: warning: unused variable ‘firstDay’ [-Wunused-variable]
      double firstDay;
             ^~~~~~~~
    315:9: warning: unused variable ‘lastDay’ [-Wunused-variable]
      double lastDay;
             ^~~~~~~
    307:28: warning: unused parameter ‘allowedMealTotal’ [-Wunused-parameter]
     void getMealAmount(double &allowedMealTotal, double &spentMealTotal){
                                ^~~~~~~~~~~~~~~~
    307:54: warning: unused parameter ‘spentMealTotal’ [-Wunused-parameter]
     void getMealAmount(double &allowedMealTotal, double &spentMealTotal){
                                                          ^~~~~~~~~~~~~~
    In function ‘int main()’:
    72:13: warning: ‘airfareFee’ may be used uninitialized in this function [-Wmaybe-uninitialized]
      airfareFee = getAirfareAmount (airfareFee);
      ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    74:15: warning: ‘carRentalFee’ may be used uninitialized in this function [-Wmaybe-uninitialized]
      carRentalFee = getCarRentalAmount (carRentalFee);
      ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    76:27: warning: ‘privateCarFee’ may be used uninitialized in this function [-Wmaybe-uninitialized]
      getPrivateVechileExpense (privateCarFee);
      ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
    92:18: warning: ‘registrationFee’ may be used uninitialized in this function [-Wmaybe-uninitialized]
      registrationFee = getRegistrationFee (registrationFee);
      ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    110:28: warning: ‘breaksfastFee’ may be used uninitialized in this function [-Wmaybe-uninitialized]
      mealTotal = breaksfastFee + lunchFee + dinnerFee; 
                  ~~~~~~~~~~~~~~^~~~~~~~~~
    110:28: warning: ‘lunchFee’ may be used uninitialized in this function [-Wmaybe-uninitialized]
    110:12: warning: ‘dinnerFee’ may be used uninitialized in this function [-Wmaybe-uninitialized]
      mealTotal = breaksfastFee + lunchFee + dinnerFee; 
      ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    145:33: warning: ‘hotelFeeTotal’ may be used uninitialized in this function [-Wmaybe-uninitialized]
      cout << "Hotel" << setw(22) << hotelFeeTotal << setw(20) << allowedHotelFee << endl;
                                     ^~~~~~~~~~~~~
    Devoted my life to programming...

  3. #3
    Registered User
    Join Date
    Dec 2018
    Posts
    3
    when i run it, it doesnt output the user for what he/she had for breakfast, lunch, and dinner on how many days he/she was gone depending on when they arrived. I am as of now looking into it.

  4. #4
    Programming Wraith GReaper's Avatar
    Join Date
    Apr 2009
    Location
    Greece
    Posts
    2,728
    At line 319, it will never execute the loop because "days" is set to zero:
    Code:
    for(int day = 1; day <= days; day++){
    Devoted my life to programming...

  5. #5
    Registered User
    Join Date
    Dec 2018
    Posts
    3
    I kind of changed it a bit and now it runs yet my if statements in the meals function aren't really working properly.I could use some help please-capture-png this is what i get on the console.
    Attached Files Attached Files

  6. #6
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    37,526
    > void getMealAmount(double &allowedMealTotal, double &spentMealTotal){
    You never compare with allowedMealTotal
    You never update spentMealTotal
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Tags for this Thread