Question: in java 7 . 1 1 Write statements that perform the following one - dimensional - array operations: Set the 1 0 elements of integer
in java
Write statements that perform the following onedimensionalarray operations:
Set the elements of integer array counts to zero.
Add one to each of the elements of integer array bonus.
Display the five values of integer array bestScores in column format.
Duplicate Elimination Use a onedimensional array to solve the following problem: Write an application that inputs five numbers, each between and inclusive. As each number is read, display it only if its not a duplicate of a number already read. Provide for the worst case, in which all five numbers are different. Use the smallest possible array to solve this problem. Display the complete set of unique values input after the user enters each new value.
Label the elements of threebyfive twodimensional array sales to indicate the order in which theyre set to zero by the following program segment:
for int row ; row sales.length; row
for int col ; col salesrowlength; col
salesrowcol;
VariableLength Argument List Write an application that calculates the product of a series of integers that are passed to method product using a variablelength argument list. Test your method with several calls, each with a different number of arguments.
CommandLine Arguments Rewrite Fig. so that the size of the array is specified by the first commandline argument. If no commandline argument is supplied, use as the default size of the array.
Using the Enhanced for Statement Write an application that uses an enhanced for statement to sum the double values passed by the commandline arguments. Hint:Use the static method parseDouble of class Double to convert a String to a double value.
Dice Rolling Write an application to simulate the rolling of two dice. The application should use an object of class Random once to roll the first die and again to roll the second die. The sum of the two values should then be calculated. Each die can show an integer value from to so the sum of the values will vary from to with being the most frequent sum, and and the least frequent. Figure shows the possible combinations of the two dice. Your application should roll the dice times. Use a onedimensional array to tally the number of times each possible sum appears. Display the results in tabular format.
Fig.
The possible sums of two dice.
Figure Full Alternative Text
Game of Craps Write an application that runs games of craps Fig and answers the following questions:
How many games are won on the first roll, second roll, twentieth roll and after the twentieth roll?
How many games are lost on the first roll, second roll, twentieth roll and after the twentieth roll?
What are the chances of winning at craps? Note: You should discover that craps is one of the fairest casino games. What do you suppose this means?
What is the average length of a game of craps?
Do the chances of winning improve with the length of the game?
Airline Reservations System A small airline has just purchased a computer for its new automated reservations system. Youve been asked to develop the new system. Youre to write an application to assign seats on each flight of the airlines only plane capacity: seats
Your application should display the following alternatives: Please type for First Class and Please type for Economy. If the user types your application should assign a seat in the firstclass section seats If the user types your application should assign a seat in the economy section seats Your application should then display a boarding pass indicating the persons seat number and whether its in the firstclass or economy section of the plane.
Use a onedimensional array of primitive type boolean to represent the seating chart of the plane. Initialize all the elements of the array to false to indicate that all the seats are empty. As each seat is assigned, set the corresponding element of the array to true to indicate that the seat is no longer available.
Your application should never assign a seat that has already been assigned. When the economy section is full, your application should ask the person if its acceptable to be placed in the firstclass section and vice versa If yes, make the appropriate seat assignment. If no display the message
"Next flight leaves in hours.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
