Write a program that asks the user for a file name

Assignment Help Basic Computer Science
Reference no: EM13883760

C++

1) Number Analysis Program

Write a program that asks the user for a file name. Assume the file contains a series of numbers, each written on a separate line. The program should read the contents of the file into an array and then display the following data:

  • The lowest number in the array
  • The highest number in the array
  • The total of the numbers in the array
  • The average of the numbers in the array

2) Monkey Business
A local zoo wants to keep track of how many pounds of food each of its three monkeys eats each day during a typical week. Write a program that stores this information in a two-dimensional 3x5 array, where each row represents a different monkey and each column represents a different day of the week. The program should first have the user input the data for each monkey. Then it should create a report that includes the following information:
• Average amount of food eaten per day by the whole family of monkeys.
• The least amount of food eaten during the week by any one monkey.
• The greatest amount of food eaten during the week by any one monkey.
Input Validation: Do not accept negative numbers for pounds of food eaten.

 

3) Larger Than n
In a program, write a function that accepts three arguments: an array, the size of the array, and a number n . Assume that the array contains integers. The function should display all of the numbers in the array that are greater than the number n

 

4) Chips and Salsa
Write a program that lets a maker of chips and salsa keep track of sales for five different types of salsa: mild, medium, sweet, hot, and zesty. The program should use two parallel 5-element arrays: an array of strings that holds the five salsa names and an array of integers that holds the number of jars sold during the past month for each salsa type. The salsa names should be stored using an initialization list at the time the name array is created. The program should prompt the user to enter the number of jars sold for each type. Once this sales data has been entered, the program should produce a report that displays sales for each salsa type, total sales, and the names of the highest selling and lowest selling products.
Input Validation: Do not accept negative values for number of jars sold.

 

5) Largest/Smallest Array Values
Write a program that lets the user enter 10 values into an array. The program should then display the largest and smallest values stored in the array.

 

6)   2D Array Operations
Write a program that creates a two-dimensional array initialized with test data. Use any data type you wish. The program should have the following functions:
getTotal This function should accept a two-dimensional array as its argument and
return the total of all the values in the array.
getAverage This function should accept a two-dimensional array as its argument and return the average of all the values in the array.
getRowTotal This function should accept a two-dimensional array as its first argument and an integer as its second argument. The second argument should be the subscript of a row in the array. The function should return the total of the values in the specified row.
getColumnTotal This function should accept a two-dimensional array as its first argument and an integer as its second argument. The second argument should be the
subscript of a column in the array. The function should return the total of the values in the specified column.
getHighestInRow This function should accept a two-dimensional array as its first argument and an integer as its second argument. The second argument should be the
subscript of a row in the array. The function should return the highest value in the specified row of the array.
getLowestInRow This function should accept a two-dimensional array as its first argument and an integer as its second argument. The second argument should be the
subscript of a row in the array. The function should return the lowest value in the specified row of the array.
Demonstrate each of the functions in this program.

Reference no: EM13883760

Questions Cloud

Discuss the paper on healthcare quality : Discuss the following in your paper:Inpatient/outpatient record documentation for diagnoses and services/ procedures. Healthcare quality
Which database model is used most frequently : Which database model is used most frequently in the modern business world? Why do you believe it is frequently used?
IRP-PPP and Speculating in Currency Derivatives : The U.S. three-month interest rate (unannualized) is 2%. The Canadian three-month interest rate (unannualized) is 3%. Assume interest rate parity exists. The expected inflation over this period is 5% in the U.S. and 3% in Canada. Determine the dollar..
Which database models are built on the inverted : Which database models are built on the inverted tree structure? What are the disadvantages of using the inverted tree structure for a database?
Write a program that asks the user for a file name : Write a program that asks the user for a file name. Assume the file contains a series of numbers, each written on a separate line. The program should read the contents of the file into an array and then display the following data:
Dollar spot exchange rate : The current Swiss franc to U.S. dollar spot exchange rate is SFr1.60/$. The expected inflation over the coming year is 2 percent in Switzerland and 5 percent in the United states. According to purchasing power parity, what is the expected value of th..
Is the interest rate parity holding : A foreign exchange arbitrageur notices that the Japanese yen to U.S. dollar spot exchange rate is ¥108/$ and the three-month forward exchange rate is ¥107.30/$. The three-month $ interest rate is 5.20 percent per Annum and the three-month ¥ interest ..
About to retire and he wants to buy an annuity : Your uncles is about to retire and he wants to buy an annuity that will provide him with $62000 of income a year for 20 Years, with the first payment coming immediately. The going rate on such annuites is 5.25%. How much would it cost him to buy the ..
Written communication is an essential tool : Written communication is an essential tool for any professional. As with any skill, writing well is the result of practice followed by feedback and the use of relevant and appropriate sources. Therefore, the quality of writing is graded as part of th..

Reviews

Write a Review

 

Basic Computer Science Questions & Answers

  Random numbers

Create a program that will generate a list of 200 random numbers (ranging from 1- 1000) and determine the medium, mode, and average of the list of numbers. Have the program display the original list and then display the list in ascending and desce..

  Difficulties for the owner of the data model

Define in your ownwords what an update anomaly is all about. Deliver a situation where a update anomaly can happen and in what way it can effect difficulties for the owner of the data model.

  Identify what kind of telecommunications

Telecommunication needs - identify what kind of telecommunications will be needed for the solution, including local connectivity inside UMUC Haircuts and internet access, if appropriate, and whether it will be used for data, voice and/or video.

  What are instance variables

What are instance variables

  Impact on business and society

Emerging Technologies and their impact on business and society

  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 ..

  Draw the final figure in red-black tree

Draw the final figure in Red-black tree by inserting the abbreviations of states NY, IL, GA, RI, MA, PA, DE, IN, VT, TX, OH, and WY into an empty tree in that order. Describe those steps where red-black rules are violated and what actions you have..

  How many function evaluation does the genetic algorithm need

How many function evaluations does the genetic algorithm need? How many function evaluations does fmincon need?

  Calculates how many km had went a man

Write a program that calculates how many km had went a man and how far he was from the initial point .

  The provided assignment submission attach file

Screenshot File Submission: You must submit the screenshot file(s) using the provided Assignment Submission Attach File function located in the Blackboard online course shell. To access Assignment Submission Attach File function, you must select the ..

  Write a simplified version of sort called my-sort-1

Write a simplified version of sort called my-sort-1 that reads from standard input, sorts lexicographically, and writes the output to standard output.

  The object''s shadow length and shadow

Simple geometry can compute the height of an object from the object's shadow length and shadow angle using the formula: tan(angleElevation) = treeHeight / shadowLength. Given the shadow length and angle of elevation, compute the tree height.

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