Coding Exercise: TryParse

This exercise on converts from one data type to another.

We'll cover the following

Problem

Write code for a console application to calculate the bill. The code should perform the following:

  • Convert the bill for each item from string to double using TryParse method.
  • Calculate the total bill by adding all values.
  • Print the total bill on the console.

The output must be in the following format:

The total bill is {total_bill} dollars.

Sample input

The program will accept three string parameters, e.g.

"15.50", "10", "24.50"

Expected output

The finished output of the program should look like this:

The total bill is 50 dollars.

Write the code in the following code box and press the “Test” button to evaluate the output of your code.

Get hands-on with 1200+ tech skills courses.