Concept explainers
Explanation of Solution
a. Output of System.out.println(values [4]); statement:
//Class definition
public class Sample {
// define main function
public static void main(String[] args) {
// Declaration of array
int [] values = {4,7,6,8,2};
// Display the value
System...
Explanation of Solution
b. Output of the statement:
Program:
//Class definition
public class Sample {
// define main function
public static void main(String[] args) {
// Declaration of array
int [] values = {4,7,6,8,2};
// Variable declaration
int x;
/* Add the value in the t...
Explanation of Solution
c. Output of the statement:
Program:
//Class definition
public class Sample {
// define main function
public static void main(String[] args) {
// Declaration of array
int [] values = {4,7,6,8,2};
// Variable declaration
int x;
Want to see the full answer?
Check out a sample textbook solutionChapter 7 Solutions
Starting Out with Java: From Control Structures through Data Structures (3rd Edition)
- (Electrical eng.) Write a program that declares three one-dimensional arrays named volts, current, and resistance. Each array should be declared in main() and be capable of holding 10 double-precision numbers. The numbers to store in current are 10.62, 14.89, 13.21, 16.55, 18.62, 9.47, 6.58, 18.32, 12.15, and 3.98. The numbers to store in resistance are 4, 8.5, 6, 7.35, 9, 15.3, 3, 5.4, 2.9, and 4.8. Your program should pass these three arrays to a function named calc_volts(), which should calculate elements in the volts array as the product of the corresponding elements in the current and resistance arrays (for example ,volts[1]=current[1]resistance[1]). After calc_volts() has passed values to the volts array, the values in the array should be displayed from inside main().arrow_forward(Electrical eng.) Write a program that specifies three one-dimensional arrays named current, resistance, and volts. Each array should be capable of holding 10 elements. Using a for loop, input values for the current and resistance arrays. The entries in the volts array should be the product of the corresponding values in the current and resistance arrays (sovolts[i]=current[i]resistance[i]). After all the data has been entered, display the following output, with the appropriate value under each column heading: CurrentResistance Voltsarrow_forward(Data processing) Write a program that uses an array declaration statement to initialize the following numbers in an array named slopes: 17.24, 25.63, 5.94, 33.92, 3.71, 32.84, 35.93, 18.24, and 6.92. Your program should locate and display the maximum and minimum values in the array.arrow_forward
- (Data processing) Write an array declaration statement that stores the following values in an array named volts: 16.24, 18.98, 23.75, 16.29, 19.54, 14.22, 11.13, and 15.39. Include these statements in a program that displays the values in the array.arrow_forward(Program) Write a declaration to store the following values in an array named rates: 12.9, 18.6, 11.4, 13.7, 9.5, 15.2, and 17.6. Include the declaration in a program that displays the values in the array by using pointer notation.arrow_forwardjava programarrow_forward
- comprog array declarationarrow_forwardLotto Program C++Write a program that simulates the Powerball lottery. In Powerball, a ticket is comprised of 5 numbers between 1 and 69 that must be unique, and a Powerball number between 1 and 26. The Powerball does not have to be unique. Hint: You can use an array to represent the 5 unique numbers between 1 and 69, and an integer variable to represent the powerball. The program asks the player if they'd like to select numbers or do a 'quickpick', where the numbers are randomly generated for them. If they opt to select numbers, prompt them to type the numbers in and validate that they are unique (except the powerball), and in the correct range. The program then generates a 'drawing' of 5 unique numbers and a Powerball, and checks it against the user's lotto ticket. It assigns winnings accordingly. Because it is so rare to win the lottery, I suggest hard coding or printing values to when testing the part of the program that assigns winnings.arrow_forwardC++ language Write a program named lower-half which takes input for a two dimensional array of 5 rows and5 columns and prints the lower half of the array.For example if user enters the following numbers:34915, 10501, 25781, 71531, 23150Then the output is:5, 01, 781, 1531, 23150arrow_forward
- programming used: javaarrow_forwardProgram 3 SRC voting application You must write a small application in JAVA that stores SRC candidate names and the votes they received. Your program must: 1. Create an array of SRC candidate names. Populate the array with ten names. 2. Create an array of votes. Populate the array with the number of votes for every candidate. The two arrays work in parallel. 3. Print the name of every candidate with his/her number of votes. 4. Print the total number of votes casted. 5. Add votes for a specific candidate. a. Read the name of the candidate b. Add one vote for the specific candidate C. Print the name of the candidate and his/her number of votesarrow_forwardjavaarrow_forward
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrEBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTMicrosoft Visual C#Computer ScienceISBN:9781337102100Author:Joyce, Farrell.Publisher:Cengage Learning,
- Programming Logic & Design ComprehensiveComputer ScienceISBN:9781337669405Author:FARRELLPublisher:CengageProgramming with Microsoft Visual Basic 2017Computer ScienceISBN:9781337102124Author:Diane ZakPublisher:Cengage LearningC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning