Welcome to the CSC Q&A, on our server named in honor of Ada Lovelace. Write great code! Get help and give help!
It is our choices... that show what we truly are, far more than our abilities.

Categories

+11 votes

I was working on question 20 on the past paper and wasn't sure if my answer was correct. Can anyone please post the answer on the discord. Thanks!

asked in CSC305 Fall 2023 by (1 point)
0

This is really confusing.

2 Answers

+6 votes

Your version:
public double calculateTotal() {
double cost = getCost();
double tax = cost * TAX_RATE;
double total = cost + tax;
return total;
}

Teammate's version:
public double calculatetotal() {
double cost = getCost();
double tax = cost * TAX_RATE;
double total = cost - tax;
double discount = getDiscount(cost);
return total - discount;
}

The correctly merged code should be:
public double calculateTotal() {
double cost = getCost();
double tax = cost * TAX_RATE;
double total = cost + tax;
double discount = getDiscount(cost);
return total-discount;
}

answered by (1 point)
+5 votes

I think professor already uploaded answer sheet in the moodle.

answered by (1 point)
...