Assignment 2 Code

download Assignment 2 Code

of 2

Transcript of Assignment 2 Code

  • 8/18/2019 Assignment 2 Code

    1/2

    // Assignment2.cpp : Defines the entry point for the console application.//

    #include "stdafx.h" //precompiled header, unique to Visual Studio 2015. Remove this if you're using a different IDE#include using namespace std;

    int main(){

    //This section instantiates and initializes the variables that are called throughout the function.

    int retailPrice = 0; //We have instantiated a variable "retailPrice" ofdata type "int" and initialized it to 0.

    double discountPrice = 0; //Instantiation" means creating the variable,i.e "double discountPrice".

    int salesTaxPct = 0; //"Initialization means setting the variable to some value, i.e " =0;".

    double totalDiscount = 0; //It is good practice to instantiate and initialize values at the very beginning of a code file--others will be looking for inputs and outputs of your program.

    double totalTax = 0;double finalPrice = 0;

    //This section takes user input to replace the initialized value of retailPrice to whatever the user (you) input into the console when the program runs. 

    cout

  • 8/18/2019 Assignment 2 Code

    2/2

    totalDiscount = retailPrice * (discountPrice / 100);totalTax = (retailPrice - totalDiscount) * (salesTaxPct / 100);finalPrice = retailPrice - totalDiscount + totalTax;

    //Display your final answer.cout