Declare an integer constant for the size of the array

Assignment Help Basic Computer Science
Reference no: EM13759551

Problem 1 - no methods required

When the user runs this block of code, the values in the array will be displayed, along with a sum value, the lowest value, and the number of occurrences of the lowest value. Appropriate data types are required, and use the Length property of the array to control all looping
constructs except the ‘foreach'. Here are the steps to follow:

a. Declare an integer constant for the SIZE of the array, the size will be 25.

b. Declare and instantiate an integer array with the name testScores using the constant SIZE. Make sure to use the "new" operator.

c. Use a ‘for' loop to populate the array with random numbers from 10 to 100 inclusive. Use constants.

d. Use a ‘while' loop structure to accumulate the values that are in the array. Store that value in a variable named sum.

e. Do not sort the array, and use a ‘do' loop to determine the lowest value in the array. Keep it simple, you do not have to create a sorting routine. (Hint: store the first value in the array into a variable called low. Inside the loop compare low to the next element in the array. If it is less, then store the array value into low. Repeat until you reach the end of the loop.)

f. Use a foreach loop to display the values in the array on one line with spaces between each number. (See below) Within this loop, count the number of times the highest value occurs in the array.

g. Using one CW, display the sum (including comma), the lowest value and the number of occurrences of the lowest value. (See below)
Required output [values listed will vary]:

Problem 1

82  87  90  91  87  88  96  92  97  100  92  92  86  94  81  88  82  92  98  92  99  85  86  81  86

Sum of values: 2,244

Lowest value: 81 occurs 2 time(s).

Problem 2

Description: Use two single dimension arrays, where one will be a Lookup Table to determine the cost of an individual item in an outlet retail store. The user will input the item (string) and the quantity (integer) purchased; then the program will determine the price (fractional number) for the item and display the total cost (fractional number) for that purchase. This will use methods, and you do not need to validate the data. Define the methods for this question directly under Main; there are comments to guide you, and above the Pause() method, and in the same Class. Reminder to not use class level variables, and accept user mixed case input for the item purchased. A fractional number is data that allows decimal points. Use the following pseudocode to guide you.

a. Declare and initialize two arrays, arrItem (Item) and arrPrice (Price) and use the “new” operator when declaring the arrays. Use the following data to initialize the arrays and do not change the order as shown.

Item           Price
laptop        925.25
keyboard    52.00
mouse        15.75
monitor       95.50

Use 1 C# statement for each array to declare and initialize the values in them. Declare the arrays within Main()

b. In Main, call the methods to get the item and the quantity. (see steps f and g)

c. In Main(), use the item array to determine the subscript/index value to use for the price.

Use a ‘for’ repetition structure and not the binary search to determine the index value to use as a Lookup in the price array.
d. If the user inputs an invalid item, display an error message that repeats the value the user entered. See example after this question. Do not add a loop to ensure valid data.

e. If the data is valid, call the CalcItemCost method (see step h) and display the total cost formatted with a dollar sign and two decimal places.

f. Method GetItem – Parameters: none; return: item Prompt for the item, and convert the input value all to lower case.

g. Method GetQuantity – Parameters: none; return: quantity of items purchased as a whole number.
Prompt for the quantity of items purchased.

h. Method CalcItemCost – Parameters: the number of items, the cost for the item; returns: the calculated total cost. A tax of 9.5% is included in the total cost, and this method will not get nor display any data to the console. Create and use a constant for the tax rate.

See examples of the prompts, and text below. Use Write instead of WriteLine for the prompts.

Required display :

Problem 2

Enter the item to purchase: Keyboard

Enter the number of items purchased: 10

Total cost for the purchase is: $569.40

Required display [Error]:

Problem 2

Enter the item to purchase: diskette

Enter the number of items purchased: 20

Invalid entry, diskette does not exist.

Problem 3

Description: Within Main(), Problem 3 curly braces, this section will call 3 methods which will be created directly below CalcTicketCost() method and right above the Pause() method. Do not declare any class level variables; use only local variables in each code block and method. Data types must match as arguments and parameters, an implicit conversion will be marked as incorrect.

a. In this code block, prompt the user for three integer values and store into appropriate data type variables. You do not need to validate the data, but you must use TryParse, and numbers can be positive or negative. Use Write instead of WriteLine for the prompts.

Within the class, create the 3 methods as describe: Product(), Division(), Average()

b. Product() with three parameters. The parameter names must be different than the variables stored in the Problem 3 code block.
Calculate the product and return the value

c. Division() with two parameters – the first parameter is the dividend, the second parameter is the divisor. The parameter names must be different than the variables stored in the Problem 3 code block.

In this example (571/13), 571 is the dividend, and 13 is the divisor

Calculate the result (no truncated values) and return the value.

Check for zero division. To keep this simple, if this error occurs, return a negative 999.99.

d. Average() with three parameters. The parameter names must be different than the variables stored in the Problem 3 code block.

e. In this Problem 3 code block, call each of the methods, with the following arguments:

a. Product: use all three input numbers as arguments

b. Division: use the “first two” input numbers as arguments

c. Average: use all three input numbers as arguments

f. Use one WriteLine to display the resulting values with appropriate labels. Show the product with commas, and no decimal places, except show the division and average results with 2 decimal places.

Required display [example1]:

Problem 3

Enter number 1: 543

Enter number 2: 000

Enter number 3: 21

The results of the three method calls are:

Product: 0

Division: -999.99

Average: 144.00

Required display [example2]:

Problem 3

Enter number 1: 25

Enter number 2: 52

Enter number 3: 33

The results of the three method calls are:

Product: 42,900

Division: 0.48

Average: 36.67

Challenge

Write a program that allows the user to enter any amount of numbers (double data type) continuously until the user enters 999; use a ‘do’ construct. Display the number of values entered and the sum of the values entered, not including 999, with commas and 2 decimal places. Use a constant for the value that ends the repetition.

Required display:

Enter a number: 1010

Enter a number: 100.10

Enter a number: 10.01

Enter a number: 999

You entered 3 numbers and the sum is 1,120.11

Reference no: EM13759551

Questions Cloud

How would you approach the physician : How would you approach the physician - What are the reasons for the unavailability of certain pharmaceutical items because of third-party payer reimbursement schemes?
Evaluate the role of religion and superstition on art : Create and explain a five-point checklist of what you should notice when seeing a work of art for the first time. Evaluate the role of religion and superstition on art and art history.
Explain the complexities of auditing a cloud computing : Explain the complexities of auditing a cloud computing deployment that uses the public model
Determination in order to maximize the firms profits : Create a report that includes a discussion and analysis regarding how such a supplier makes such a determination in order to maximize the firm's profits.
Declare an integer constant for the size of the array : When the user runs this block of code, the values in the array will be displayed, along with a sum value, the lowest value, and the number of occurrences of the lowest value.
What is the impact of online training on education : What is the impact of online training on education
What is your interpretation of the conclusion : What is your interpretation of the conclusion? Do you agree with Owens, or do you believe there might be some hope for the Little Elk people to enter a new era beyond the close of this story?
Define a dummy variable equal to 1 : Define a dummy variable equal to 1 for years after 1979. Include this dummy in equation (10.15) to see if there is a shift in the interest rate equation after 1979. what do you conclude ?
Effectively communicate with stakeholders orally : Effectively communicate with stakeholders orally, visually, and in writing to determine stakeholders' business requirements, explain how their requirements will be met, and provide ongoing audience-appropriate information

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Which value of border-collapse will give each cell

Which value of border-collapse will give each cell of a table a border that can be specified independently of adjacent cells?

  What is data integrity and in what way it is implemented

What is data integrity and in what way it is implemented in DBMS MS Access

  What is the expected number of floors the elevator stops

What is the expected number of floors the elevator stops

  Basic business skills play a role in your professional life

How will basic business skills play a role in your professional life?

  Explaining data-tlb hit and data-cache hit

Upon a load instruction, event "data-TLB hit" followed by "data-cache hit" is the most probable to occur among four possibilities of Cartesian product.

  Write a program to manage a dictionary

Then ask whether the user wants to add this new word to the dictionary. If the answer is yes, do so and go back to request the next word.

  Add an overloaded assignment operator

Add an overloaded assignment operator, a copy constructor to the Cube class, and a printCube member function in the attached lab6_ex2_copy_operator_starter.cpp. This starter is incomplete, you have to fill the right stuff in the blank in order to ..

  Effective user-level thread implementation

What must a kernel provide for an effective user-level thread implementation? Do you have immediate help for this answer?

  What is the difference between intrinsic and acquired value

What is the difference between intrinsic value and acquired value?

  What visual effects were you able to achieve

What visual effects were you able to achieve with the tools that you used in the activity?  Do you think these effects enabled you to improve the quality of the image?  Why or Why not?

  How many rfid tags be produced annually meet that demand

suppose that each of the 300 million people in the united state fully consumes two packages of goods a day bearing RFID tags. how many RFID tags have to be produced annually to meet that demand

  Review julie hilden arguments

Review Julie Hilden's arguments

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd