Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

IN C# - Problem #4 While Loop: Cha-Ching! While loops are an excellent choice when you need code to repeat an unknown number of times.

IN C# - Problem #4 While Loop: Cha-Ching! While loops are an excellent choice when you need code to repeat an unknown number of times.

In this problem the user is given a gift card for a store. They are going to keep buying items until they go over the amount of their card.

You will ask the user for the gift card amount first. Then create a while loop that will start deducting each purchase from the card. As long as the money on the card is above zero, the while loop should continue looping. When the user spends their entire gift card, stop the loop and tell them how much they went over by.

User Inputs: o Initial Gift Card Amount

o Inside of the loop, keep asking the user how much their purchase is.

Result To Print Out:

o For each purchase (hint: every time it loops) the loop should tell the user how much money they have left that they could spend. With your current purchase of $X, you can still spend $X.

o After the user exceeds their card, With your last purchase of $X, you have used your gift card up and still owe $X.

Data Sets To Test: o Gift Card Amount 30.00

Purchase1- 5.00 Results - With your current purchase of $5.00, you can still

spend $25.00.

Purchase2- 10.50 Results - With your current purchase of $10.50, you can still

spend $14.50.

Purchase3- 16.00 Results - With your last purchase of $16.00, you have used your

gift card up and still owe $1.50.

o Test One Of Your Own & Write both of these results in your comment section.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Practical Oracle8I Building Efficient Databases

Authors: Jonathan Lewis

1st Edition

0201715848, 978-0201715842

Students also viewed these Databases questions

Question

What is an interface? What keyword is used to define one?

Answered: 1 week ago

Question

Provide examples of KPIs in Human Capital Management.

Answered: 1 week ago

Question

What are OLAP Cubes?

Answered: 1 week ago