1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
NemiM [27]
3 years ago
11

Complete the GiftCard class shown below. A GiftCard keeps track of the current balance on the card. A gift card starts with a be

ginning balance. A GiftCard can be used to make a purchase, funds can be added to a GiftCard, and the balance can be checked at any time. The balance can never be negative. If the amount added to the card is $100 or more, a bonus of $10 is also added.
public class GiftCard
{
// declare instance variables

// precondition: the starting balance is not negative
// postcondition: all instance variables are initialized
public GiftCard(double startBal)
{

}

// postcondition: amount is subtracted from balance
// if there are insufficient funds, the balance is set to zero and a message
// is displayed to indicate how much of the transaction is still owed
public void spendFunds(double amount)
{

}
// postcondition: amount is added to balance, if the amount is at least 100 dollars,
// 10 dollars is added
public void addFunds(double amount)
{

}

// postcondition: the current balance is returned
public double checkBalance()
{

}
}

Computers and Technology
1 answer:
Aleonysh [2.5K]3 years ago
3 0

Answer:

I solved this program using C# and Visual Studio. The output of this program is given attached image. I initialized the start balance with 300$.

the code of this program is given in explanation section

Explanation:

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

namespace GiftCard

{

   class Program

   {

       static void Main(string[] args)

       {

           Program a = new Program();

            //Console.WriteLine("Please enter the starting balance");// you can uncomment this statement if you enter startbalance at run time

            //double startingBalance = Convert.ToDouble(Console.ReadLine());//initializing starting balance at run time

           double startingBalance = 300; //let suppose we enter 300

           a.GiftCard(startingBalance);//balance is set to starting blance value i.e. enter by user

           Console.ReadLine();// here we pause, and check variables values from GiftCard constructor

           a.spendFunds(100);// here we assume to spend 100$

           Console.ReadLine();//here we check the spendFund function and about its values

          a.addFunds(600);// here we enter fund 600$

           Console.ReadLine();

           a.checkBalance(); //here we are checking balance;    

       }

       // declare instance variables

       // precondition: the starting balance is not negative

       // postcondition: all instance variables are initialized

       private double balance=0;// keep the balance

       private double purchase;//how much you spend or purchasing value

       

       public void GiftCard(double startBal)

       {

           

           balance = startBal;

           if (balance < 0)

           {

               Console.WriteLine("Balance is negative, Please enter positive balance");

               balance = 0;

           }

           else

           {

               balance = startBal;

               Console.WriteLine(balance);

           }

       }

       // postcondition: amount is subtracted from balance

       // if there are insufficient funds, the balance is set to zero and a message

       // is displayed to indicate how much of the transaction is still owed

       public void spendFunds(double amount)

       {

             purchase = balance - amount;// suppose you spend 300 that mean you have purchased of 300

           if (purchase <0) //if your spending is more than your balance

           {

               

               double owed = amount - balance;// how much amount you need more for this transaction

               balance = 0;

               Console.WriteLine("The transaction is still owed "+owed+"$");

           }

           else if(purchase==0) // if after doing purchase, your balance is equal to zero

           {

               Console.WriteLine("you have no balance after this transaction");

           }

           else

           {

               balance = balance - amount;// if your purchase is less than the balance

               Console.WriteLine("your balance after spending " + amount +"$ is " + balance+"$");

           }

       }

       // postcondition: amount is added to balance, if the amount is at least 100 dollars,

       // 10 dollars is added

       public void addFunds(double amount)

       {

           if (amount >= 100)// if you add fund more than 100$

           {

               balance = balance + amount + 10; //then add the amount + 10$ as bonus into already existing balance

               Console.WriteLine("balance is after adding funds i.e " + amount +"$  is "+ balance+"$");

           }

           else// if added fund is less than 100$

           {

               balance = balance + amount;

           }

       }

// postcondition: the current balance is returned

       public double checkBalance()//check balance anytime

       {

           

           Console.WriteLine("balance is "+balance+"$");

           Console.ReadLine();

           return balance;

       }

   }

}

   

You might be interested in
NAT is able to stop ________. Group of answer choices a) scanning probes sniffers from learning anything about the internal IP a
Nikitich [7]

Answer:

The answer to this question is option "b".

Explanation:

NAT stands for Network Address Translation. It translates the IP addresses of computers in a local network to a single IP address. NAT is responsible for stopping both scanning probes and sniffers from learning anything about the internal IP address and its hosting. Sniffing is a process of monitoring and catching all data packets moving within a distributed network. It uses the network or system administrator to control and troubleshoot fiber traffic. Scanning probes stands for Scanning Probes Microscopes (SPMs) used to create images of nanoscale covers the structures, including atoms. In this scanning method, a computer collects data that are used to create an image of the surface.

8 0
3 years ago
Read 2 more answers
Construct a regular expression that recognizes the following language of strings over the alphabet {0 1}:
vovikov84 [41]

Answer:

00(01)*+|(01)*+101|00(01)*+101

Rest detail is in explanation.

Explanation:

(01)* means all the strings comprising of 0 and 1

when we add + the set includes empty sets as well. and for or we use union, and this can be done using the | sign.

And for concatenation, we have like 00(01)* etc. Hence, the above regular expression.

5 0
3 years ago
How do i know my child's login info for parent infinite campus
Oliga [24]

Answer:

Logging in from a Web Browser

Visit infinitecampus.com and click Login at the top right.

Search for your District Name and State. Select your district from the list.

Click Parent/Student.

Click either Campus Parent or Campus Student.

Enter the Username and Password provided by your school. ...

Click Log In!

Explanation:

5 0
3 years ago
Elena is starting a new nonprofit organization that provides professional-looking clothes for women who need to go on job interv
frutty [35]

Answer:

Excel is a multipurpose program that is useful in many different ways and not just in payroll. It has uses from Accounting to scientific research and everything in-between.

Elena might not need it for payroll but there are other ways to use Excel such as:

  • Database of Donor details - Elena can use Excel to keep a list of the businesspeople who donate their old clothes to the organization. She can also add details to these names such as when they donated, the frequency at which they have donated, what they donated and the like. The donor details will therefore be organized such that information on donors can be easy to acquire for whatever reason it is needed for.
  • Inventory - Excel can be used to keep an inventory list of the clothes that the organization has in stock. This will enable them better serve those they want to help as well as ensuring accountability in the workplace. A well kept inventory list will enable all sorts of analysis to be carried out such as which types of clothes are most in stock, which clothes are needed, which clothes are preferred and the like.
3 0
3 years ago
George wants to pursue a career in web technology as a web developer. Which certifications can help him as a web developer?
skelet666 [1.2K]

Answer:Google Analytics IQ.

he can use this

Explanation:

3 0
3 years ago
Other questions:
  • Given two int variables, i and j, which have been declared and initialized, and two other int variables, itemp and jtemp, which
    14·1 answer
  • What are some of the other operations that might be implemented for a queue?
    14·1 answer
  • Which tab allows you to modify the width of a page margins in Microsoft word?
    7·2 answers
  • While doing online research you enter this keyword search with a truncation character: man* Which of the following would not be
    15·1 answer
  • ​ In addition to using national weather sites, you should supplement the local weather information with all of the following EXC
    12·1 answer
  • create a function that draws a certain number of spaces, followed by a certain number of stars, followed by a newline.
    6·1 answer
  • Write passage on computer virus​
    10·2 answers
  • Makayla is cre iting a brochure for her computer consulting company. She designed the layout and placed a banner containing the
    6·1 answer
  • Consider Emily's balance statement:
    6·1 answer
  • unlike tv or newspaper ads, internet communications are interactive, and consumers can choose which messages and information the
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!