Question
Create a program named SalesTaxDemo that declares an array of 10 Sale objects. Prompt the user for data for each object and display the 10
Create a program named SalesTaxDemo that declares an array of 10 Sale objects. Prompt the user for data for each object and display the 10 objects. The program should accept input and display output in the same format as the sample program output below.
Data fields for Sale objects include:
- InventoryNumber - An inventory number (as a string)
- amount - Amount of the sale (as a double)
- tax - Tax owed (as a double)
Include a property with get and set accessors for the first two data fields, but make the tax owed a read-only property.
The tax should be calculated whenever the amount of the sale is set. Assume that the tax rate is 8 percent for the first $100 and 6 percent for any amount greater than $100.
Sample Program Ouput:
Enter inventory number #1 >> 1 Enter amount of sale >> 200 Enter inventory number #2 >> 2 Enter amount of sale >> 900 Enter inventory number #3 >> 5 Enter amount of sale >> 1200 Enter inventory number #4 >> 18 Enter amount of sale >> 37000 Enter inventory number #5 >> 12 Enter amount of sale >> 1500 Enter inventory number #6 >> 91 Enter amount of sale >> 100024 Enter inventory number #7 >> 88 Enter amount of sale >> 8091 Enter inventory number #8 >> 102 Enter amount of sale >> 400675 Enter inventory number #9 >> 21 Enter amount of sale >> 1900 Enter inventory number #10 >> 28 Enter amount of sale >> 12000 Sale # 1 Amount: 1 Sale $200.00 Tax is $14.00 Sale # 2 Amount: 2 Sale $900.00 Tax is $56.00 Sale # 3 Amount: 5 Sale $1,200.00 Tax is $74.00 Sale # 4 Amount: 18 Sale $37,000.00 Tax is $2,222.00 Sale # 5 Amount: 12 Sale $1,500.00 Tax is $92.00 Sale # 6 Amount: 91 Sale $100,024.00 Tax is $6,003.44 Sale # 7 Amount: 88 Sale $8,091.00 Tax is $487.46 Sale # 8 Amount: 102 Sale $400,675.00 Tax is $24,042.50 Sale # 9 Amount: 21 Sale $1,900.00 Tax is $116.00 Sale # 10 Amount: 28 Sale $12,000.00 Tax is $722.00
In order to prepend the $ to currency values, the program will need to use the CultureInfo.GetCultureInfo method. In order to do this, include the statement using System.Globalization; at the top of your program and format the output statements as follows: WriteLine("This is an example: {0}", value.ToString("C", CultureInfo.GetCultureInfo("en-US")));
This is my code, can you review it?
// I have removed "using static System.Console" because I am using .Net 4.5 compiler
// So if you found error while running you can include it in your program
using System;
public class SalesTaxDemo
{
public static void Main()
{
int time = 10; // number of objects
Sale[] sale = new Sale[10]; // creating objects
for(int i=0; i<10; i++) sale[i] = new Sale(); //initializing objects
for(int i=0; i
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started