
given an char array, char_array[100], which one correctly assign “happy” to this array?
a. char_array[0] = ‘h’; char_array[1] = ‘a’; char_array[2] = ‘p’; char_array[3] = ‘p’; char_array[4] = ‘y’;
b. char_array[0] = ‘h’; char_array[1] = ‘a’; char_array[2] = ‘p’; char_array[3] = ‘p’; char_array[4] = ‘y’; char_array[5] = ‘\0’;
c. char_array[0] = “h”; char_array[1] = “a”; char_array[2] = “p”; char_array[3] = “p”; char_array[4] = “y”; char_array[5] = “\0”;
d. char_array[1] = ‘h’; char_array[2] = ‘a’; char_array[3] = ‘p’; char_array[4] = ‘p’; char_array[5] = ‘y’; char_array[6] = ‘\0’;
5. given a string variable, string str; str = “Friday”, after doing str.append(“ happy.”), which one is the correct result of string str?
a. Fridayhappy.
b. happy. Friday
c. Friday happy.
d. happy.Friday
6. Given the below code, what’s the printed-out result?
class Date{
public:
int year;
Date(int yr);
void print();
};
Date:: Date(int yr){year = yr;}
int main(){
Date d(2022);
d.year = 2099;
Date d2(2000);
cout << d2.year <<endl;
return 0;
}
a. 2099
b.2022
c. 0
d.2000

Step by stepSolved in 2 steps

- JAVA PROGRAM Chapter 7. PC #16. 2D Array Operations Write a program that creates a two-dimensional array initialized with test data. Use any primitive data type that you wish. The program should have the following methods: • getTotal. This method should accept a two-dimensional array as its argument and return the total of all the values in the array. • getAverage. This method should accept a two-dimensional array as its argument and return the average of all the values in the array. • getRowTotal. This method 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 method should return the total of the values in the specified row. • getColumnTotal. This method 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 method should return the…arrow_forwardFYI: Please write the code in Pseudocode (no programming language please) 1. Write pseudocode to load a single array with data. Then search that array for a match. Here are the specifics. You do NOT have to write the entire program. Load the array with data from a file named customerNumbers Ask the user to enter their customer number Search the array for the customer number If you find a match output FOUND If there is no match output NOT FOUNDarrow_forwardProgramming language: Processing from Java Question attached as photo Topic: Use of Patial- Full Arraysarrow_forward
- The logic will allow the user to: Load a single dimensional array of size 50 with a random number The random number will range from 1 to 1,000 (you may have duplicate values) Find the highest value and the index location that it was in Find the smallest value and the index location that it was in Display the array’s contents. Display the highest value and its index location Display the lowest value and its index location Allow the user to execute this application multiple times (some sort of loop?) You will need one for loop to load the array as well as one or two for loops to search that array. The rand also has a “nasty” tendency to create the same results repeatedly in an exe. To avoid that, we have to “shuffle the deck” every time. This ensures that all numbers are an equal probability of appearing and not the same set of values (would create a boring game). // Add this to "shuffle the deck" every time to ensure that // different values could occur else the exe produces the…arrow_forwardAssume an array is defined as int[] nums = {7, 15, 23, 5};. Which of the following would place the values in the array in descending numeric order? a. Array.Reverse(nums); b. Array.Reverse(nums); Array.Sort(nums); c. Array.Sort(nums); d. Array.Sort(nums); Array.Reverse(nums);arrow_forward10. Lottery Application Write a Lottery class that simulates a lottery. The class should have an array of five integers named lotteryNumbers. The constructor should use the Random class (from the Java API) to generate a random number in the range of 0 through 9 for each element in the array. The class should also have a method that accepts an array of five integers that represent a per- son's lottery picks. The method is to compare the corresponding elements in the two arrays and return the number of digits that match. For example, the following shows the lotteryNumbers array and the user's array with sample numbers stored in each. There are two matching digits (elements 2 and 4). lotteryNumbers array: User's array: 7 4 4 2 1 3 7 3 In addition, the class should have a method that returns a copy of the lotteryNumbers array. Demonstrate the class in a program that asks the user to enter five numbers. The program should display the number of digits that match the randomly generated…arrow_forward
- Problem Description - JAVA PROGRAMMING Use a Two-dimensional (3x3) array to solve the following problem: Write an application that inputs nine numbers, each of which is between 1 and 10, inclusive. Display the array after the user inputs each value. Rotate/flip the array by changing places. Make the rows columns and vice versa. You have to move the elements to their new locations. Remember to validate the input and display an error message if the user inputs invalid data. Documentation and the screenshot(s) of the results. Example: 1 2 3 4 5 6 7 8 9 the result will be : 1 4 7 2 5 8 3 6 9arrow_forwardLet numbers be an array defined as follows. int numbers[5][7]; Assume that the array has been filled with values. Which of the following blocks of code calculates the row totals of the 2-dim array and store them in the 1-dim array named totals? int totals[5] = {0}; for (int row = 0; row < 5; ++row) { int total = 0; for (int col = 0; col < 7; ++col) { total += numbers[row][col]; } totals[row] = total; } int totals[7] = {0}; for (int col = 0; col < 7; ++col) { int total = 0; for (int row = 0; row < 5; ++row) { total += numbers[row][col]; } totals[col] = total; } O None of these int totals[7] = {0}; for (int row = 0; row < 7; ++row) { int total = 0; for (int col = 0; col < 5; ++col) { total += numbers[row][col]; } totals[row] = total; }arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education





