1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
kakasveta [241]
3 years ago
15

In JAVA please:

Computers and Technology
1 answer:
blagie [28]3 years ago
5 0

Answer:

import java.util.Scanner;

public class ArraysKeyValue {

public static void main (String [] args) {

final int SIZE_LIST = 4;

int[] keysList = new int[SIZE_LIST];

int[] itemsList = new int[SIZE_LIST];

int i;

keysList[0] = 13;

keysList[1] = 47;

keysList[2] = 71;

keysList[3] = 59;

itemsList[0] = 12;

itemsList[1] = 36;

itemsList[2] = 72;

itemsList[3] = 54;  

/* Your solution goes here */

for ( i = 0; i < SIZE_LIST; i++){

 if (keysList[i]>50){

  System.out.println(itemsList[i] + " ");  }  }

System.out.println("");

}

}

Explanation:

I will explain the whole program flow.

  • There are two arrays here
  • keysList and itemsList
  • The first list (keysList) contains the following elements:

13 element at first position of the array (0th index)

47 element at second  position of the array (1st index)

71 element at third position of the array (2nd index)

59 element at fourth position of the array (3rd index)

  • The other list (itemsList) contains the following elements:

12 element at first position of the array (0th index)

36 element at second  position of the array (1st index)

72 element at third position of the array (2nd index)

54 element at fourth position of the array (3rd index)

  • The size of the array elements is fixed which is 4 and is stored in the variable SIZE_LIST.
  • Then the loop starts. The loop contains a variable i which is initialized to 0. First it checks if the value of i is less than the size of the list. It is true as SIZE_LIST=4 and i=0.
  • So the program control enters the body of the loop.
  • In first iteration, IF condition checks if the i-th element of the keysList is greater than 50. As i=0 So the element at 0th index of the keysList is 13 which is not greater than 50 so the body of IF statement will not execute as the condition evaluates to false. The value of i increments by 1 so now i becomes 1.
  • In next iteration loop again checks if the value of i is less than the size of the list which is true again so the body of the loop executes.
  • IF condition checks if the i-th element of the keysList is greater than 50. As i=1 So the element at 1st index of the keysList is 47 which is not greater than 50 so the body of IF statement will not execute as the condition evaluates to false. The value of i is incremented by 1 so now i becomes 2.
  • In next iteration loop again checks if the value of i is less than the size of the list which is true again as i= 2 which is less than SIZE_LIST so the body of the loop executes.
  • IF condition checks if the i-th element of the keysList is greater than 50. As i=2 So the element at 2nd index of the keysList is 71 which is greater than 50 so the body of IF statement is executed as the condition evaluates to true. So in the body of the IF statement there is a print statement which prints the i-th element of the itemsList. As i = 2 so the value at the index 2 of the itemsList is displayed in the output which is 72. Next value of i is incremented by 1 so now i becomes 3.
  • In next iteration loop again checks if the value of i is less than the size of the list which is true again as i= 3 which is less than SIZE_LIST so the body of the loop executes.
  • IF condition checks if the i-th element of the keysList is greater than 50. As i=3 So the element at 3rd index of the keysList is 59 which is greater than 50 so the body of IF statement is executed as the condition evaluates to true. So in the body of the IF statement there is a print statement which prints the i-th element of the itemsList. As i = 3 so the value at the index 3 of the itemsList is displayed in the output which is 54. Next value of i is incremented by 1 so now i becomes 4.
  • In next iteration loop again checks if the value of i is less than the size of the list which is now false as i=4 which is equal to the SIZE_LIST= 4. So the loop breaks.
  • So the output of the above program is:

72

54

You might be interested in
How to reset maintenance light on toyota camry?
choli [55]
Best thing to Do is unplug your batteries or replace your bulbs<span />
7 0
4 years ago
_is a computer network created for an individual person
hichkok12 [17]

Answer:

Personal area network

Explanation:

is correct 100% sure

3 0
4 years ago
Write the definitions of two classes Day and Night. Both classes have no constructors, methods or instance variables. Note: For
Colt1911 [192]

Answer:

class Day

{

}  

class Night

{

}

Explanation:

Given

Two classes named: Day and Night

Requirement: Both classes have no constructors, methods or instance variables. should not be declared using the public visibility modifier.

The syntax to define a class in object oriented programming is

modifier class classname {

 // Constructor

 constructor(variablename) { ......}

 // Methods

 methods() { ... }

 ...

}

Access modifiers (or access specifiers) are keywords in object-oriented languages that set the accessibility of classes, methods, and other members. Examples are private, public, protected, etc.

Going by the syntax above to define class Day

Day

private class Day{

 // Constructor

 constructor(duration)

{

this.duration = duration;

}

 // Methods

CalculateDate() { ... }

}

But the question states that both classes have no constructors, methods or instance variables. should not be declared using the public visibility modifier.

So, class Day will be defined as follows

class Day

{

}

It could also be declared using visibility modifiers other than public modifier.  So, class Day will be defined as follows

private class Day

{

}

and

protected class Day

{

}

Similarly, class Night can be defined as follows

class Night

{

}

private class Night

{

}

and

protected class Night

{

}

4 0
3 years ago
Create a website for an online movie rental store, using HTML (and any other client technologies) and PHP. The website should in
FromTheMoon [43]

Answer:

HTML and PHP code is given below using 10 movie selections

Explanation:

movierentalstore.php:-

<html>

<head>

<title> Online movie rent store </title>

 

</head>

<body bgcolor="blue" alink="white " vlink="white " link="white">

<br>

<hr size="5" color="white">

<center><font face="Monotype corsiva" size="25" color="yellow"> @@ Movies available for rent right now @@ </font></center>

<font face="times new roman" size=6 color="white">

<ol type="1">

<li> Batman $40 * Cast :- Michael Keaton , Jack Nicholson , Kim Basinger / Robert Wuhl *

</li>

<li> Godzilla 2019 $30 * Cast :- Kyle Chandler, Vera Farmiga, Millie Bobby Brown * </li>

<li> Wonder Woman $50</li>

<li> Terminator $10</li>

<li> Avengers : End Game $20</li>

<li> Harry Potter $30</li>

<li> Annabelle $20</li>

<li> hustlers $10</li>

<li> Joker $50</li>

<li> The Lion king $15</li>

 

</ol>

</font>

<a href="renting.php" alink="white"> Click here to rent the movie ... </a>

<br>

<a href="review.php" alink="white"> Click here to review the movie ... </a>

</body>

</html>

review.php :-

<html>

<head>

<title> Reviewing Page </title>

</head>

<body bgcolor="green" > <hr size="5" color="white">

 

<h1><center><font face="Monotype corsiva" size="25" color="yellow"> Review movie </center></font> </h1> <hr size="5" color="white">

<font size="6" face="times new roman" color="yellow">

<form method="GET">

<label>Select movie</label>

<select name="movie1">

<option value="1" > batman</option>

<option value="2" > godzilla</option>

<option value="3" > wonder woman </option>

<option value="4" > terminator</option>

<option value="5" > avengers</option>

<option value="6" > Harry potter</option>

<option value="7" > Anabelle</option>

<option value="8" > Hustlers</option>

<option value="9" > Joker</option>

<option value="10" > The lion king</option>

<br>

</select>

<br><br>

Username :- <input type="text" name="name1" required="" > </input>

<br><br>

Review :- <input type="text" name="review" required="" > </input>

<br><br>

<label>Select rating</label>

<select name="rating">

<option value="1" > 1</option>

<option value="2" > 2</option>

<option value="3" > 3 </option>

<option value="4" > 4</option>

<option value="5" > 5</option>

<br>

 

</select>

 

<input type="submit" name="submit" required="" value="Submit">

<input type="reset" name="reset" required="" value="Reset">

<hr size="5" color="white">

 

 

</form>

<?php

if(isset($_GET["submit"]))

{ $name1=$_GET["name1"];

$r=$_GET["review"];

$re=$_GET["rating"];

$m=$_GET["movie1"];

echo "Movie name :- ".$m." <br>";

echo "Username :- ".$name1." <br>";

echo "Review :- ".$r." <br>";

echo "Rating :- ".$re. "Stars "." <br>" ;

echo "Successfully submitted.. Thankks for your feedback " ;

}

 

?>

</div>

</body>

</html>

rating,php

<html>

<head>

<title> Renting Page </title>

</head>

<body bgcolor="red"> <hr size="5" color="white">

<h1><center><font face="Monotype corsiva" size="25" color="yellow"> Renting movie </center></font> </h1> <hr size="5" color="white">

<form method="GET">

 

<label>Select movie</label>

<select name="movie1">

<option value="1" > batman</option>

<option value="2" > godzilla</option>

<option value="3" > wonder woman </option>

<option value="4" > terminator</option>

<option value="5" > avengers</option>

<option value="6" > Harry potter</option>

<option value="7" > Anabelle</option>

<option value="8" > Hustlers</option>

<option value="9" > Joker</option>

<option value="10" > The lion king</option>

</select>

 

<input type="submit" name="submit" required="" value="Submit">

<input type="reset" name="reset" required="" value="Reset">

<hr size="5" color="white">

 

 

</form>

</div>

<div class="php">

<?php

if(isset($_GET["submit"]))

{ $movie1=$_GET["movie1"];

echo "Selected movie is : ".$movie1;

echo "<br> </br>";

echo "Amount charged : " ;

switch($movie1)

{

case 1 : echo " 42 dollars" ;

break;

case 2: echo "31.5 dollars" ;

break;

case 3 : echo "52.5 dollars" ;

break;

case 4: echo " 10.5 dollars" ;

break;

case 5 : echo " 21 dollars" ;

break;

case 6 : echo "31.5 dollars" ;

break;

case 7: echo "21 dollars" ;

break;

case 8 : echo " 10.5 dollars" ;

break;

case 9: echo " 52.5 dollars" ;

break;

case 10 : echo " 16 dollars" ;

break;

}

echo "Successfully rented" ;

}

 

?>

</div>

</body>

</html>

7 0
3 years ago
Rachael has been posting negative comments on several of her peers' social media pages. Which of the six Ps is Rachael abusing?
posledela
The answer is D. Personification
4 0
4 years ago
Other questions:
  • Microsoft windows server and linux are examples? of:
    12·1 answer
  • In GIMP, the ( ) displays the image that the user is currently working on
    12·1 answer
  • Which of the following lists contains the five essential elements of a computer? Group of answer choices: 1. inputs, returns, pr
    11·1 answer
  • If an additional term relates to payment, quality, quantity, price, time, and place of delivery, the CISG considers the added te
    12·1 answer
  • What is the unemployment rate if the GDP gap is 13.5%?<br><br> A. 6.25%<br> B. 6.75%<br> C. 6.7%
    8·1 answer
  • Which user characteristic may not be used to change keyword bids in adwords?:?
    11·1 answer
  • Using the drop-down menu, complete these sentences to describe algorithms. Algorithms are instructions to solve a problem. Algor
    12·2 answers
  • Which of the following characteristics differentiates PCM from BWF audio
    15·2 answers
  • How do news organizations primarily create revenue?
    12·2 answers
  • In a mobile app for computer technicians in a large college, an initial trigger event could be ____.
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!