CUPCAKE - Task 2 Ahmad Solehuddin Bin Nizar (2019252848)

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 15

NAME : AHMAD SOLEHUDDIN BIN NIZAR

STUDENT ID# : 2019252848

COURSE : CSC425

GROUP# : EC2203A1

ASSIGN# : ASSIGNMENT 2 (Task 2)

DUE DATE : 2/12/2020

PROGRAM DESCRIPTION : A PROGRAM WHICH CAN CALCULATE THE TOTAL PRICE (BEFORE AND

……………….AFTER DISCOUNT) AND DELIVERY CHARGE BASED ON THE DESTINATION

LECTURER’S NAME : MISS NORHARZIANA BINTI YAHAYA RASHDI


/*

Name: Ahmad Solehuddin bin Nizar

Sid#: 2019252848

Course: CSC425

Group#: EC2203A1

Assign#: Assignment 2(Task 2)

Due Date: 2/12/2020

Program Description: A program which can calculate the total price (before and after discount) and delivery charge based on the destination.

*/

#include <iostream>

using namespace std;

int main (){

// Variables

float price, total_price, delivery_charge, after_discount, total_total;

int cake_code, pieces, destination_code;

// Welcome Message

cout << "Welcome to SweetCupCakes Sdn. Bhd" << endl;

cout << "We sell cupcakes and provide delivery service for our dearest customer around Klang Valley, Negeri Sembilan and Melaka!" << endl;

cout << "Its your lucky day! You can enjoy our variation of promotion if u buy more than 20 pieces of cupcakes :)" << endl;

cout << endl;

// Price of Cake

cout << "Here is our list of cupcake and its price per piece: " << endl;

cout << "1. Chocolate Moist : RM 2.30 " << endl;

cout << "2. Red Velvet : RM 3.00 " << endl;

cout << "3. Banana : RM 1.50 " << endl;

cout << endl;

// Promotion:

cout << "Promotion (%) discount based on number of cake u ordered: " << endl;

cout << "1. Less than 20 pieces : No discount " << endl;

cout << "2. 20 to 29 pieces : 10% discount " << endl;

cout << "3. 30 to 49 pieces : 20% discount " << endl;

cout << "4. More than 50 pieces : 30% discount " << endl;

cout << endl;

// Delivery rate according to Area:

cout << "Delivery charge according to area: " << endl;

cout << "1. Klang Valley : RM 10.00 " << endl;


cout << "2. Negeri Sembilan : RM 20.00 " << endl;

cout << "3. Melaka : RM 35.00 " << endl;

cout << endl;

cout <<
"______________________________________________________________________________________________________________________________
" << endl;

cout << endl;

// Input statement

cout << "Please enter your selected cupcake using number below : " << endl;

cout << "1 for Chocolate Moist" << endl;

cout << "2 for Red Velvet" << endl;

cout << "3 for Banana" << endl;

cin >> cake_code;

cout << "Enter the amount of cupcakes that you want: " << endl;

cin >> pieces;

cout << "Enter your destination for delivery using number below: " << endl;

cout << "1 for Klang Valley" << endl;

cout << "2 for Negeri Sembilan" << endl;

cout << "3 for Melaka" << endl;

cin >> destination_code;

cout << endl;

// Output statement

if (cake_code==1){

cout << "Your selected cupcake is: Chocolate Moist" << endl;

cout << endl;

if (pieces < 20){

total_price = pieces * 2.30;

cout << "Your selected amount does not reach for any discount." << endl;

cout << "Hence, your total price now is: RM" << total_price << endl;

cout << endl;

if (destination_code==1){

delivery_charge = 10.00;

total_total = total_price + delivery_charge;

cout << "Your selected delivery area is: Klang Valley (RM10)" << endl;

cout << "The total price you have to pay (including delivery) is: RM" << total_total << endl;

else if (destination_code==2){

delivery_charge = 20.00;

total_total = total_price + delivery_charge;


cout << "Your selected delivery area is: Negeri Sembilan (RM20)" << endl;

cout << "The total price you have to pay (including delivery) is: RM" << total_total << endl;

else if(destination_code==3){

delivery_charge = 35.00;

total_total = total_price + delivery_charge;

cout << "Your selected delivery area is: Melaka (RM35)" << endl;

cout << "The total price you have to pay (including delivery) is: RM" << total_total;

else if (destination_code<=0 or destination_code>3){

cout << "Ooops, I think that you have entered an invalid value at the selection of destination XD" << endl;

cout << "Hence, I cannot reveal the total amount you have to pay :)";

else if (pieces >= 20 && pieces < 30){

total_price = pieces * 2.30;

after_discount = 0.90 * total_price;

cout << "Your selected amount of cupcake qualified you for a 10% discount." << endl;

cout << "Your total price before discount is: RM" << total_price << endl;

cout << "Total price after discount is: RM" << after_discount << endl;

cout << endl;

if (destination_code==1){

delivery_charge = 10.00;

total_total = after_discount + delivery_charge;

cout << "Your selected delivery area is: Klang Valley (RM10)" << endl;

cout << "The total price you have to pay (including delivery) is: RM" << total_total << endl;

else if (destination_code==2){

delivery_charge = 20.00;

total_total = after_discount + delivery_charge;

cout << "Your selected delivery area is: Negeri Sembilan (RM20)" << endl;

cout << "The total price you have to pay (including delivery) is: RM" << total_total << endl;

else if(destination_code==3){

delivery_charge = 35.00;

total_total = after_discount + delivery_charge;

cout << "Your selected delivery area is: Melaka (RM35)" << endl;

cout << "The total price you have to pay (including delivery) is: RM" << total_total;
}

else if (destination_code<=0 or destination_code>3){

cout << "Ooops, I think that you have entered an invalid value at the selection of destination XD" << endl;

cout << "Hence, I cannot reveal the total amount you have to pay :)";

else if (pieces >= 30 && pieces < 50){

total_price = pieces * 2.30;

after_discount = 0.80 * total_price;

cout << "Your selected amount of cupcake qualified you for a 20% discount." << endl;

cout << "Your total price before discount is: RM" << total_price << endl;

cout << "Total price after discount is: RM" << after_discount << endl;

cout << endl;

if (destination_code==1){

delivery_charge = 10.00;

total_total = after_discount + delivery_charge;

cout << "Your selected delivery area is: Klang Valley (RM10)" << endl;

cout << "The total price you have to pay (including delivery) is: RM" << total_total << endl;

else if (destination_code==2){

delivery_charge = 20.00;

total_total = after_discount + delivery_charge;

cout << "Your selected delivery area is: Negeri Sembilan (RM20)" << endl;

cout << "The total price you have to pay (including delivery) is: RM" << total_total << endl;

else if(destination_code==3){

delivery_charge = 35.00;

total_total = after_discount + delivery_charge;

cout << "Your selected delivery area is: Melaka (RM35)" << endl;

cout << "The total price you have to pay (including delivery) is: RM" << total_total;

else if (destination_code<=0 or destination_code>3){

cout << "Ooops, I think that you have entered an invalid value at the selection of destination XD" << endl;

cout << "Hence, I cannot reveal the total amount you have to pay :)";

else if (pieces >= 50){

total_price = pieces * 2.30;

after_discount = 0.70 * total_price;


cout << "Your selected amount of cupcake qualified you for a 30% discount." << endl;

cout << "Your total price before discount is: RM" << total_price << endl;

cout << "Total price after discount is: RM" << after_discount << endl;

cout << endl;

if (destination_code==1){

delivery_charge = 10.00;

total_total = after_discount + delivery_charge;

cout << "Your selected delivery area is: Klang Valley (RM10)" << endl;

cout << "The total price you have to pay (including delivery) is: RM" << total_total << endl;

else if (destination_code==2){

delivery_charge = 20.00;

total_total = after_discount + delivery_charge;

cout << "Your selected delivery area is: Negeri Sembilan (RM20)" << endl;

cout << "The total price you have to pay (including delivery) is: RM" << total_total << endl;

else if(destination_code==3){

delivery_charge = 35.00;

total_total = after_discount + delivery_charge;

cout << "Your selected delivery area is: Melaka (RM35)" << endl;

cout << "The total price you have to pay (including delivery) is: RM" << total_total;

else if (destination_code<=0 or destination_code>3){

cout << "Ooops, I think that you have entered an invalid value at the selection of destination XD" << endl;

cout << "Hence, I cannot reveal the total amount you have to pay :)";

else if (pieces <= 0){

cout << "Ooops, I think that you have entered an invalid value at the selection amount of cupcakes XD ";

else if (cake_code==2){

cout << "Your selected cupcake is: Red Velvet" << endl;

cout << endl;

if (pieces < 20){

total_price = pieces * 3.00;

cout << "Your selected amount does not reach for any discount." << endl;

cout << "Hence, your total price now is: RM" << total_price << endl;

cout << endl;

if (destination_code==1){
delivery_charge = 10.00;

total_total = total_price + delivery_charge;

cout << "Your selected delivery area is: Klang Valley (RM10)" << endl;

cout << "The total price you have to pay (including delivery) is: RM" << total_total << endl;

else if (destination_code==2){

delivery_charge = 20.00;

total_total = total_price + delivery_charge;

cout << "Your selected delivery area is: Negeri Sembilan (RM20)" << endl;

cout << "The total price you have to pay (including delivery) is: RM" << total_total << endl;

else if(destination_code==3){

delivery_charge = 35.00;

total_total = total_price + delivery_charge;

cout << "Your selected delivery area is: Melaka (RM35)" << endl;

cout << "The total price you have to pay (including delivery) is: RM" << total_total;

else if (destination_code<=0 or destination_code>3){

cout << "Ooops, I think that you have entered an invalid value at the selection of destination XD" << endl;

cout << "Hence, I cannot reveal the total amount you have to pay :)";

else if (pieces >= 20 && pieces < 30){

total_price = pieces * 3.00;

after_discount = 0.90 * total_price;

cout << "Your selected amount of cupcake qualified you for a 10% discount." << endl;

cout << "Your total price before discount is: RM" << total_price << endl;

cout << "Total price after discount is: RM" << after_discount << endl;

cout << endl;

if (destination_code==1){

delivery_charge = 10.00;

total_total = after_discount + delivery_charge;

cout << "Your selected delivery area is: Klang Valley (RM10)" << endl;

cout << "The total price you have to pay (including delivery) is: RM" << total_total << endl;

else if (destination_code==2){

delivery_charge = 20.00;

total_total = after_discount + delivery_charge;


cout << "Your selected delivery area is: Negeri Sembilan (RM20)" << endl;

cout << "The total price you have to pay (including delivery) is: RM" << total_total << endl;

else if(destination_code==3){

delivery_charge = 35.00;

total_total = after_discount + delivery_charge;

cout << "Your selected delivery area is: Melaka (RM35)" << endl;

cout << "The total price you have to pay (including delivery) is: RM" << total_total;

else if (destination_code<=0 or destination_code>3){

cout << "Ooops, I think that you have entered an invalid value at the selection of destination XD" << endl;

cout << "Hence, I cannot reveal the total amount you have to pay :)";

else if (pieces >= 30 && pieces < 50){

total_price = pieces * 3.00;

after_discount = 0.80 * total_price;

cout << "Your selected amount of cupcake qualified you for a 20% discount." << endl;

cout << "Your total price before discount is: RM" << total_price << endl;

cout << "Total price after discount is: RM" << after_discount << endl;

cout << endl;

if (destination_code==1){

delivery_charge = 10.00;

total_total = after_discount + delivery_charge;

cout << "Your selected delivery area is: Klang Valley (RM10)" << endl;

cout << "The total price you have to pay (including delivery) is: RM" << total_total << endl;

else if (destination_code==2){

delivery_charge = 20.00;

total_total = after_discount + delivery_charge;

cout << "Your selected delivery area is: Negeri Sembilan (RM20)" << endl;

cout << "The total price you have to pay (including delivery) is: RM" << total_total << endl;

else if(destination_code==3){

delivery_charge = 35.00;

total_total = after_discount + delivery_charge;

cout << "Your selected delivery area is: Melaka (RM35)" << endl;

cout << "The total price you have to pay (including delivery) is: RM" << total_total;

}
else if (destination_code<=0 or destination_code>3){

cout << "Ooops, I think that you have entered an invalid value at the selection of destination XD" << endl;

cout << "Hence, I cannot reveal the total amount you have to pay :)";

else if (pieces >= 50){

total_price = pieces * 3.00;

after_discount = 0.70 * total_price;

cout << "Your selected amount of cupcake qualified you for a 30% discount." << endl;

cout << "Your total price before discount is: RM" << total_price << endl;

cout << "Total price after discount is: RM" << after_discount << endl;

cout << endl;

if (destination_code==1){

delivery_charge = 10.00;

total_total = after_discount + delivery_charge;

cout << "Your selected delivery area is: Klang Valley (RM10)" << endl;

cout << "The total price you have to pay (including delivery) is: RM" << total_total << endl;

else if (destination_code==2){

delivery_charge = 20.00;

total_total = after_discount + delivery_charge;

cout << "Your selected delivery area is: Negeri Sembilan (RM20)" << endl;

cout << "The total price you have to pay (including delivery) is: RM" << total_total << endl;

else if(destination_code==3){

delivery_charge = 35.00;

total_total = after_discount + delivery_charge;

cout << "Your selected delivery area is: Melaka (RM35)" << endl;

cout << "The total price you have to pay (including delivery) is: RM" << total_total;

else if (destination_code<=0 or destination_code>3){

cout << "Ooops, I think that you have entered an invalid value at the selection of destination XD" << endl;

cout << "Hence, I cannot reveal the total amount you have to pay :)";

else if (pieces <= 0){

cout << "Ooops, I think that you have entered an invalid value at the selection amount of cupcakes XD ";

else if (cake_code==3){

cout << "Your selected cupcake is: Banana" << endl;


cout << endl;

if (pieces < 20){

total_price = pieces * 1.50;

cout << "Your selected amount does not reach for any discount." << endl;

cout << "Hence, your total price now is: RM" << total_price << endl;

cout << endl;

if (destination_code==1){

delivery_charge = 10.00;

total_total = total_price + delivery_charge;

cout << "Your selected delivery area is: Klang Valley (RM10)" << endl;

cout << "The total price you have to pay (including delivery) is: RM" << total_total << endl;

else if (destination_code==2){

delivery_charge = 20.00;

total_total = total_price + delivery_charge;

cout << "Your selected delivery area is: Negeri Sembilan (RM20)" << endl;

cout << "The total price you have to pay (including delivery) is: RM" << total_total << endl;

else if(destination_code==3){

delivery_charge = 35.00;

total_total = total_price + delivery_charge;

cout << "Your selected delivery area is: Melaka (RM35)" << endl;

cout << "The total price you have to pay (including delivery) is: RM" << total_total;

else if (destination_code<=0 or destination_code>3){

cout << "Ooops, I think that you have entered an invalid value at the selection of destination XD" << endl;

cout << "Hence, I cannot reveal the total amount you have to pay :)";

else if (pieces >= 20 && pieces < 30){

total_price = pieces * 1.50;

after_discount = 0.90 * total_price;

cout << "Your selected amount of cupcake qualified you for a 10% discount." << endl;

cout << "Your total price before discount is: RM" << total_price << endl;

cout << "Total price after discount is: RM" << after_discount << endl;

cout << endl;

if (destination_code==1){
delivery_charge = 10.00;

total_total = after_discount + delivery_charge;

cout << "Your selected delivery area is: Klang Valley (RM10)" << endl;

cout << "The total price you have to pay (including delivery) is: RM" << total_total << endl;

else if (destination_code==2){

delivery_charge = 20.00;

total_total = after_discount + delivery_charge;

cout << "Your selected delivery area is: Negeri Sembilan (RM20)" << endl;

cout << "The total price you have to pay (including delivery) is: RM" << total_total << endl;

else if(destination_code==3){

delivery_charge = 35.00;

total_total = after_discount + delivery_charge;

cout << "Your selected delivery area is: Melaka (RM35)" << endl;

cout << "The total price you have to pay (including delivery) is: RM" << total_total;

else if (destination_code<=0 or destination_code>3){

cout << "Ooops, I think that you have entered an invalid value at the selection of destination XD" << endl;

cout << "Hence, I cannot reveal the total amount you have to pay :)";

else if (pieces >= 30 && pieces < 50){

total_price = pieces * 1.50;

after_discount = 0.80 * total_price;

cout << "Your selected amount of cupcake qualified you for a 20% discount." << endl;

cout << "Your total price before discount is: RM" << total_price << endl;

cout << "Total price after discount is: RM" << after_discount << endl;

cout << endl;

if (destination_code==1){

delivery_charge = 10.00;

total_total = after_discount + delivery_charge;

cout << "Your selected delivery area is: Klang Valley (RM10)" << endl;

cout << "The total price you have to pay (including delivery) is: RM" << total_total << endl;

else if (destination_code==2){

delivery_charge = 20.00;

total_total = after_discount + delivery_charge;

cout << "Your selected delivery area is: Negeri Sembilan (RM20)" << endl;

cout << "The total price you have to pay (including delivery) is: RM" << total_total << endl;
}

else if(destination_code==3){

delivery_charge = 35.00;

total_total = after_discount + delivery_charge;

cout << "Your selected delivery area is: Melaka (RM35)" << endl;

cout << "The total price you have to pay (including delivery) is: RM" << total_total;

else if (destination_code<=0 or destination_code>3){

cout << "Ooops, I think that you have entered an invalid value at the selection of destination XD" << endl;

cout << "Hence, I cannot reveal the total amount you have to pay :)";

else if (pieces >= 50){

total_price = pieces * 1.50;

after_discount = 0.70 * total_price;

cout << "Your selected amount of cupcake qualified you for a 30% discount." << endl;

cout << "Your total price before discount is: RM" << total_price << endl;

cout << "Total price after discount is: RM" << after_discount << endl;

cout << endl;

if (destination_code==1){

delivery_charge = 10.00;

total_total = after_discount + delivery_charge;

cout << "Your selected delivery area is: Klang Valley (RM10)" << endl;

cout << "The total price you have to pay (including delivery) is: RM" << total_total << endl;

else if (destination_code==2){

delivery_charge = 20.00;

total_total = after_discount + delivery_charge;

cout << "Your selected delivery area is: Negeri Sembilan (RM20)" << endl;

cout << "The total price you have to pay (including delivery) is: RM" << total_total << endl;

else if (destination_code==3){

delivery_charge = 35.00;

total_total = after_discount + delivery_charge;

cout << "Your selected delivery area is: Melaka (RM35)" << endl;

cout << "The total price you have to pay (including delivery) is: RM" << total_total;

else if (destination_code<=0 or destination_code>3){

cout << "Ooops, I think that you have entered an invalid value at the selection of destination XD" << endl;

cout << "Hence, I cannot reveal the total amount you have to pay :)";
}

else if (pieces <= 0){

cout << "Ooops, I think that you have entered an invalid value at the selection amount of cupcakes XD ";

else if (cake_code <= 0 or cake_code > 3){

cout << "Ooops, I think that you have entered an invalid value in the selection of cupcakes XD ";

return 0;

}
Sample Input and Output

You might also like