c# - How do I return 2 values for this method? -


this current code:

public static double calculatetip(double totalexpense) {     const double tip1 = 0.15;      return totalexpense * tip1; }  //calculation tip 2  public static double calculatetip2(double totalexpense) {     const double tip2 = 0.20;      return totalexpense * tip2;  } 

how can possibly combine 2 1 method? program runs perfect , according instruction professor, used 5 methods instead of 4. apparently must able combine two, otherwise wouldn't wants 4 methods in instructions.

final output of program looks this

                      tip calculator please enter total:  clear console                        tip calculator total before taxes , tip: 50.00 (user input obviously) taxes : $4.50 tip 15%: $7.50 total including taxes , 15% tip: $62.00 tip 20%: 10:00 total including taxes , 20% tip: $64.50 

consider using tuple

tuple<double, double> calculatetip(double totalexpense) {     const double tip1 = 0.15;     const double tip2 = 0.20;     return tuple.create<double, double>(totalexpense * tip1, totalexpense * tip2); } 

Popular posts from this blog