Lab 2: Tax Calculator

In this hands-on activity we will be making a simple tax calculator.

Example

It is currently tax season, so this is pretty on topic. But, what we're making is a lot simpler than something I could use to file my taxes.

What we want is a program that will answer the question, "How much money is my purchase after tax is added?"

For example, in JavaScript:

// Input Variables
var purchase = 100.00;
var tax_rate = 1.06;

// Let's calculate the answer
var total = tax_rate * purchase;

// Let's format the message
var message = "The total on a purchase of "+purchase+
              " dollars with a tax rate of "+tax_rate+
              " is "+total+
              " dollars.";

// And let's output the message and be done
console.log(message);

Questions

Part 1

  1. Answer for each language: What is the default "Hello World" code for your language in RexTester [1]? How would you modify that code so it outputs "Hello James Bond, I've been waiting for you" instead? Demonstrate your answers with screenshots.
  2. What is a variable?
  3. What is a variable type?
  4. Answer for each language, research as necessary: How do you create variables in your language? How would you create a variabled named bank_balance with the value -0.05? Demonstrate your answer with screenshots.
  5. What is the difference between integers and doubles?
  6. What is a string? How does it differ from integers and doubles?
  7. Answer for each language: Visit the Rosetta Code page for Simple Tasks [2], then read up on your language for the String Concatenation and String Interpolation tasks. How would you create and output a message like "Your current bank balance is <bank_balance>"? Demonstrate your answer with screenshots.

Links:

  1. http://rextester.com/
  2. https://rosettacode.org/wiki/Category:Simple

Part 2

  1. Pick one language from your group. What language did you choose for this task and why?
  2. In your chosen language, use RexTester to program the tax calculator program described above. Change the value of the purchase variable to 99.99 and the tax_rate variable to 1.07. Demonstrate your answer with screenshots.

Part 3

For each of the following, demonstrate your answer with screenshots of the program you wrote above being used to answer the word problem:

  1. What is the total on a purchase of 1234.56 at a tax rate of 1.23?
  2. What is the total on a purchase of 19.99 at a tax rate of 1.05?
  3. What is the total on a purchase of a cheeseburger (1.49) plus fries (0.49) plus a large drink (0.99), at a tax rate of 1.06?