Concept explainers
Write a
How many numbers will you enter?
4
Enter 4 integers, one per line :
2
1
1
2
The sum is 6.
The numbers are :
2, Which is 33.3333% of the sum.
1, Which is 16.6666% of the sum.
1, Which is 16.6666% of the sum.
2, Which is 33.3333% of the sum.
Want to see the full answer?
Check out a sample textbook solutionChapter 7 Solutions
Java: An Introduction to Problem Solving and Programming (7th Edition)
Additional Engineering Textbook Solutions
Starting Out With Visual Basic (8th Edition)
Starting Out with C++: Early Objects (9th Edition)
Introduction To Programming Using Visual Basic (11th Edition)
C How to Program (8th Edition)
Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)
Problem Solving with C++ (10th Edition)
- 2. A store owner wants the total sales for 2020. Write a program that will load an array with 12 months of sales. Use iomanip to make a nice-looking chart that shows the monthly sales, the month with the highest sales, lowest sales, and average for the year sales. January ……………. $50,000 February…………… $60,000 March ……………….$80,000 April ………………..$106,000 May …………………..$50,000 June ………………..$190,000 July ………………….$900,000 August …………… $102,000 September ………..$70,000 October …………..$700,000 November………… $90,000 December …………$90,000 Total Sales for the year 2020 was ………………….………$ The month with highest sales was ****** at ………..$ The month with lowest sales was ****** at ………...$ The average of sales for the year was ……………………$ C++arrow_forwardCreate a array of size n and poulate it with random numbers in range @ to 150. Print the average value in the array. Take n as input by user. Write whole code in main function only.Given n>=1 and narrow_forward2. Rotate Left k cells Use Python Consider an array named source. Write a method/function named rotateLeft( source, k) that rotates all the elements of the source array to the left by 'k' positions. You must execute the method by passing an array and number of cells to be shifted. After calling the method, print the array to show whether the elements have been shifted properly. Example: source=[10,20,30,40,50,60] rotateLeft(source,3) After calling rotateLeft(source,3), printing the array should give the output as: [ 40, 50, 60, 10, 20, 30]arrow_forward
- Write a program that uses a 2-D array to store the highest and lowest temperatures for each month of the year. The program should output the average high, average low, and highest and lowest temperatures of the year. Your program must consist of the following methods with their appropriate parameters: a.) getData: This method reads and stores the data in the 2-D array. b.) averageHigh: This method calculates and returns the average high temperature of the year. c.) averageLow: This method calculates and returns the average low temperature of the year. d.) indexHighTemp: This method returns the index of the highest temperature in the array. e.) indexLowTemp: This method returns the index of the lowest temperature in the array. Use the following input: High temp for each month: 30 40 45 60 70 90 89 95 79 90 70 40 Low temp for each month: 10 -10 20 30 50 75 85 79 50 80 30 20arrow_forwardThe Lo Shu Magic Square is a grid with 3 rows and 3 columns shown below. The Lo Shu Magic Square has the following properties: The grid contains the numbers 1 – 9 exactly The sum of each row, each column and each diagonal all add up to the same number. This is shown below: Write a program that simulates a magic square using 3 one dimensional parallel arrays of integer type. Do not use two-dimensional array. Each one the arrays corresponds to a row of the magic square. The program asks the user to enter the values of the magic square row by row and informs the user if the grid is a magic square or not. Project Specifications Input for this project: Values of the grid (row by row) Output for this project: Whether or not the grid is magic square Processing Requirements Use the following template to start your project: #include<iostream> using namespace std; // Global constants const int ROWS = 3; // The number of rows in the array const int COLS = 3; // The number of columns…arrow_forwardThe Lo Shu Magic Square is a grid with 3 rows and 3 columns shown below. The Lo Shu Magic Square has the following properties: The grid contains the numbers 1 – 9 exactly The sum of each row, each column and each diagonal all add up to the same number. This is shown below: Write a program that simulates a magic square using 3 one dimensional parallel arrays of integer type. Do not use two-dimensional array. Each one the arrays corresponds to a row of the magic square. The program asks the user to enter the values of the magic square row by row and informs the user if the grid is a magic square or not. Processing Requirements - c++ Use the following template to start your project: #include<iostream> using namespace std; // Global constants const int ROWS = 3; // The number of rows in the array const int COLS = 3; // The number of columns in the array const int MIN = 1; // The value of the smallest number const int MAX = 9; // The value of the largest number //…arrow_forward
- Create a program that asks the user to type in 10 words one by one. The program should store each word in an array. The program should then go through the array of words one by one and it should upper case all the odd index words, and lowercase all the even index words. (Consider zero is even). Then the program should go through the array and print off the entire "sentence" word by word onto a single line, adding a period to the end. Then print off the list as an array using the Arrays.toString() command A sample output might look like. Please type in word #1 : Alpha Please type in word #2 : bravo Please type in word #3 : charlie Please type in word #4 : delta Please type in word #5 : echo Please type in word #6 : foxtrot Please type in word #7 : golf Please type in word #8 : hotel Please type in word #9 : india Please type in word #10 : juliet Your sentence is: alpha BRAVO charlie DELTA echo FOXTROT golf HOTEL india JULIET. As a string it would look like: [alpha,BRAVO, charlie, DELTA,…arrow_forwardRetailItem Class Write a class named Retailltem that holds data about an item in a retail store. The class should have the following fields: • description. The description field references a String object that holds a brief description of the item. • unitsOnHand. The unitsOnHand field is an int variable that holds the number of units currently in inventory. • price. The price field is a double that holds the item's retail price. Write a constructor that accepts arguments for each field, appropriate mutator methods that store values in these fields, and accessor methods that return the values in these fields. Once you have written the class, write a separate program that creates three RetailItem objects and stores the following data in them: Description Units on Hand Price Item #1 Jacket 12 59.95 Irem #2 Designer Jeans 34.95 [rem #3 Shirt 24.95arrow_forwardWrite a java program to perform the following operations on an array 1. populate an array with 10 integers between -100 and 100 (not hard-coded) create a menu after populating the array to enable the user to select an option to perform 2. find and display the negative numbers in the array 4. display all odd numbers in the array 5. display all numbers in the array 6. display all numbers in the array in reverse order 7. display all 5 multiples 8. display the count of the negative numbers in the array 10 display the count of the positive numbers in the array submit the source code, and the output (make sure to label all outputs)arrow_forward
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning