Question

In: Computer Science

Complete the 3 programming problems in this assignment by using Microsoft Visual Studio Suite. Compile your...

Complete the 3 programming problems in this assignment by using Microsoft Visual Studio Suite. Compile your solutions for each problem solved in a Word or Google document which includes (a) the pseudocode, (b) the C# codes and (c) the execution result (screen capture just the answer part using Snipping Tool, avoiding non-related or blank spaces). Notice for readability, that the (a) & (b) are in text mode and the (c) is in image mode. Use proper titles and wording in the results, such as Console.WriteLine("The total change to be made is {0:C}.", change); so that the results could be easily understood by a third party reader. For all 3 questions, assign the provided initial values to the variables or constants in the source code as input.

You may need to save the snipped image as a JPG file and then insert the file into the document, especially when you use a Google doc. Create just one document for all 3 solutions in this assignment. You may create the document directly from a cloud service or from you PC first and then upload it to a cloud. The possible cloud service could be Google Drive, Microsoft OneDrive, Dropbox, etc. To submit the document, click the "Write Submission" button under this assignment. Then use the opened editor box to submit the web address of your document on the cloud or, if you are not yet able to use a cloud service, submit the document as an attached file.


Q2. Write a C# program that the number of twenty, ten, five, dollar, quarter, dime, nickel, and penny that a customer should get back as change. The goal is to use the least numbers of bills and coins. Run your program once by initializing the change as $77.92. Then change the source code to initialize the change as $23.27. Record both C# codes and results as images in the submission document. (Hint: It's easier to convert $77.92 to 7792 pennies and use the penny as the basic unit to for all conversions. Alternatively, you may use the dollar for the whole dollar part and the penny for less than one dollar part as the basic units.)   

Solutions

Expert Solution

using System;

public class changeMaker
{
   ///
   public static void Main(string[] args)
   {
       Scanner keyboard = new Scanner(System.in);
       int price;
       int provided;
       int change;
       Console.Write("Enter the purchase price:");
       price = (int) Math.Round(keyboard.NextDouble() * 100);
       Console.Write("Enter the amount given by the customer:");
       provided = (int) Math.Round(keyboard.NextDouble() * 100);
       if (provided > price)
       {
           Console.WriteLine("The customer should be given the change as follows:");
           change = provided - price;
           // Since you multiplied by 100 you have to divide by 2000 to get the number of twenties for change.

           int twenties = change / 2000;
           if (twenties > 0)
           { //if the change is less than $20 this will be a zero
               change = change % 2000; // this resets the value of change to the remainder after the twenties are calculated but only if there was at least enough to make one twenty
               Console.WriteLine(twenties + " $20 bill(s)");
           }
           int tens = change / 1000;
           if (tens > 0)
           {
               change = change % 1000;
               Console.WriteLine(tens + " $10 bill(s)");
           }
           int fives = change / 500;
           if (fives > 0)
           {
               change = change % 500;
               Console.WriteLine(fives + " $5 bill(S)");
           }
           int ones = change / 100;
           if (ones > 0)
           {
               change = change % 100;
               Console.WriteLine(ones + " $1 bill(s)");
           }
           int quarters = change / 25;
           if (quarters > 0)
           {
               change = change % 25;
               Console.WriteLine(quarters + " quarter coin(s)");
           }
           int dimes = change / 10;
           if (dimes > 0)
           {
               change = change % 10;
               Console.WriteLine(dimes + " dime coin(s)");
           }
           int nickels = change / 5;
           if (nickels > 0)
           {
               change = change % 5;
               Console.WriteLine(nickels + " nickel coin(s)");
           }
           int pennies = change;
           Console.WriteLine(pennies + " penny coin(s)");
       }
       if (provided < price)
       { // this statement is saying that if the customer doesn't pay enough, it will tell the user
           Console.Write("Not enough money!");
       }
       else if (provided == price)
       { // this statement says if the amount provided matches the price, then there is no change necessary
           Console.Write("No change is necessary!");
       }
   }
}


Related Solutions

Complete the 3 programming problems in this assignment by using Microsoft Visual Studio Suite. Compile your...
Complete the 3 programming problems in this assignment by using Microsoft Visual Studio Suite. Compile your solutions for each problem solved in a Word or Google document which includes (a) the pseudocode, (b) the C# codes and (c) the execution result (screen capture just the answer part using Snipping Tool, avoiding non-related or blank spaces). Notice for readability, that the (a) & (b) are in text mode and the (c) is in image mode. Use proper titles and wording in...
C# Programming language!!! Using visual studios if possible!! PrimeHealth Suite You will create an application that...
C# Programming language!!! Using visual studios if possible!! PrimeHealth Suite You will create an application that serves as a healthcare billing management system. This application is a multiform project (Chapter 9) with three buttons. The "All Accounts" button allows the user to see all the account information for each patient which is stored in an array of class type objects (Chapter 9, section 9.4).The "Charge Service" button calls the Debit method which charges the selected service to the patient's account...
MUST BE WRITTEN IN ASSEMBLY LANGUAGE ONLY AND MUST COMPILE IN VISUAL STUDIO You will write...
MUST BE WRITTEN IN ASSEMBLY LANGUAGE ONLY AND MUST COMPILE IN VISUAL STUDIO You will write a simple assembly language program that performs a few arithmetic operations. This will require you to establish your programming environment and create the capability to assemble and execute the assembly programs that are part of this course. Your \student ID number is a 7-digit number. Begin by splitting your student ID into two different values. Assign the three most significant digits to a variable...
Answer the questions below as indicated. Note that you have to complete these using Visual Studio...
Answer the questions below as indicated. Note that you have to complete these using Visual Studio 2019. Upload the source code (.cpp) of your applications. Upload a separate (.cpp) file for each question. 1-Create a C++ program which adds two numbers and displays the sum. 2-Create a C++ program which calculates and displays the area of a rectangle. 3-Create a C++ program which calculates and displays the average of four numbers.. 4-Complete questions 3 of the chapter 3 Programming Exercises...
This programming assignment will consist of a C++ program. Your program must compile correctly and produce...
This programming assignment will consist of a C++ program. Your program must compile correctly and produce the specified output. Please note that your programs should comply with the commenting and formatting described in the Required Program Development Best Practices document that has been discussed in class and is posted to the eLearning system. Please see this descriptive file on the eLearning system for more details. The name to use in the main configuration screen text box Name: [ ] in...
Programming Language: C# CheckingAccount class You will implement the CheckingAccount Class in Visual Studio. This is...
Programming Language: C# CheckingAccount class You will implement the CheckingAccount Class in Visual Studio. This is a sub class is derived from the Account class and implements the ITransaction interface. There are two class variables i.e. variables that are shared but all the objects of this class. A short description of the class members is given below: CheckingAccount Class Fields $- COST_PER_TRANSACTION = 0.05 : double $- INTEREST_RATE = 0.005 : double - hasOverdraft: bool Methods + «Constructor» CheckingAccount(balance =...
Create an ASP.Net Website using Visual Studio with C#: Create a simple calculator that has 3...
Create an ASP.Net Website using Visual Studio with C#: Create a simple calculator that has 3 text boxes: 2 of them to enter numbers, the 3rd one displays the results Create 4 buttons to add, subtract, multiply, and divide Prevent the user from entering text in the number fields Display a message indicating “cannot divide by” when the user click “/” and there is a zero the in the second box Create two additional buttons: - One to store data...
This is a discussion question for my csc 252 computer programming c++ visual studio so post...
This is a discussion question for my csc 252 computer programming c++ visual studio so post in c++ visual studio so that i can copy and paste thank you. In Object Oriented Programming, classes represent abstractions of real things in our programs. We must quickly learn how to define classes and develop skills in identifying appropriate properties and behaviors for our class. To this end, pick an item that you work with daily and turn it into a class definition....
Objectives: 1. To get familiar with C# programming language 2. To get familiar with Visual Studio...
Objectives: 1. To get familiar with C# programming language 2. To get familiar with Visual Studio development environment 3. To practice on writing a C# program Task 1: Create documentation for the following program which includes the following: a. Software Requirement Specification (SRS) b. Use Case Task 2: Write a syntactically and semantically correct C# program that models telephones. Your program has to be a C# Console Application. You will not implement classes in this program other than the class...
Assignment: Complete the following problems. You must show your work on the math problems to get...
Assignment: Complete the following problems. You must show your work on the math problems to get full credit. Every student is responsible for completing their own responses to the following problems. 1. Eastern Engineering has the following base-case estimates for a new small engine assembly project:               Capital Investment = $15,000,000               Fixed Costs = $3,250,000               Variable Costs = $600 per unit               Price per Unit = $1,000               Demand = 20,000 units per year Service Life = 12...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT