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
Alexeev081 [22]
3 years ago
15

Write a for loop to populate array userguesses with num_guesses integers. read integers using scanner. ex: if num_guesses is 3 a

nd user enters 9 5 2, then userguesses is {9, 5, 2} java
Computers and Technology
2 answers:
xxMikexx [17]3 years ago
6 0
Import java.util.Scanner; public class StoreGuesses {   public static void main (String [] args) {
   public static void main (String [] args) {      Scanner scnr = new Scanner(System.in);
      Scanner scnr = new Scanner(System.in);      final int NUM_GUESSES = 3;
      final int NUM_GUESSES = 3;      int[] userGuesses = new int[NUM_GUESSES];
      int[] userGuesses = new int[NUM_GUESSES];      int i = 0;
      int i = 0;             for (i = 0; i < NUM_GUESSES; ++i) {         
                  userGuesses[i] = scnr.nextInt();
      }
       for (i = 0; i < NUM_GUESSES; ++i){         System.out.print(userGuesses[i] + " ");
         System.out.print(userGuesses[i] + " ");      }
      }       return;   }
   }}
}
Damm [24]3 years ago
3 0

Answer:

For displaying the number guesses in array user guess, first declare the number guess variable and set it to 3. After this, store the number guesses in array user guesses variables. Then declare the for loop and run till the number of guesses. Finally, print the number of guesses using print statement.

Further explanation:

Following is the JAVA program to populate the array user guesses with number guesses integers.

Code:

import java.util.Scanner;

//class definition

public class NumberGuesses

{

public static void main (String [] args)  

{

Scanner scnr = new Scanner(System.in);

//initialize the variable number guesses with 3

final int num_guesses=3;

//store the number guesses variable in an array

int[] user_guesses = new int[num_guesses];

int i = 0;

//for loop declaration

for (i = 0; i < num_guesses; ++i)

{

user_guesses[i] = scnr.nextInt();

}

for (i = 0; i < num_guesses; ++i)

{

//print the output

System.out.print(user_guesses[i] + " ");

}

}

return;

}

Learn more:

1. A company that allows you to license software monthly to use online is an example of ? brainly.com/question/10410011

2. Prediction accuracy of a neural network depends on _______________ and ______________. brainly.com/question/10599832

3. The shape of our galaxy was determined ‘on the inside looking out' by surveying the milky way using ____________ telescopes. brainly.com/question/7866623

4. List 3 characteristics of the ideal encryption scheme. brainly.com/question/3000161

Answer details:

Grade: College Engineering

Subject: Computer Science and Engineering

Chapter: JAVA Programming

Keyword:

C Language, C++ language, JAVA, python, for loop, populate, array, read, scanner, class, num_guesses, user_guesses, enters, 9, 5, 2, variable, function, print, condition, true, false, return, system.out.print

You might be interested in
Someone please help fast! I’m taking the test rn and I don’t understand this!!!!!!
andrezito [222]

Answer:

the mistake that was made by allen is that he was not suppose to hire a highly proficient technician to install the heating and cooling system in the granary.

7 0
3 years ago
Use JavaWrite a program that will simulate a change machine found at cash registers. Input the amount due and amount paid from t
Ksju [112]

Answer:

Here is the JAVA program:

import java.util.Scanner;  //to accept input from user

public class Main { // class name

 public static void main(String [] args) {  // start of main method

   Scanner input = new Scanner(System.in);  // creates Scanner class object to take input from user

   System.out.println("Please Enter the Cost of the Item: ");  // prompts user to enter the cost of item

   double itemCost = input.nextDouble();  //scans and reads the input value of item cost

   System.out.println("Please Enter the Amount Paid: ");  // prompts user to enter the amount paid

   double amount = input.nextDouble();  //scans and reads the value of amount from user

   int change = (int)(amount * 100 - itemCost * 100);  //compute the remaining amount i.e. change

   System.out.println("Change Owed: " + change / 100.0);  // displays the owed change

   int quarters = change / 25;  // computes the value for quarters

   change = change % 25;  // compute the quarters remaining

   int dimes = change / 10;  //  computes dimes

   change = change % 10;  //  computes dimes remaining

   int nickels = change / 5;  // computes nickels

   change = change % 5;  // compute nickels remaining

   int pennies = change;  // computes pennies

   System.out.println("Quarters: " + quarters);  // displays computed value of quarters

   System.out.println("Dimes: " + dimes);  // displays value of dimes

   System.out.println("Nickels: " + nickels);  // displays value of nickels

   System.out.println("Pennies: " + pennies);   }} //displays value of pennies

Explanation:

I will explain the program with an examples.

Suppose the user enters 4.57 as cost of the item and 5.00 as amount paid. Then the program works as follows:

Change is computed as

change = (int)(amount * 100 - itemCost * 100);

This becomes;

change = (int)(5.00 * 100 - 4.57 * 100)

            = 500 - 457

change = 43

Now the change owed is computed as:

change / 100.0 = 43/100.0 = 0.43

Hence change owed = 0.43

Next quarters are computed as:

quarters = change / 25;

This becomes:

quarters = 43/25

quarters = 1

Now the remaining is computed as:

   change = change % 25;

This becomes:

   change = 43 % 25;

  change = 18

Next the dimes are computed from remaining value of change as:

dimes = change / 10;

dimes = 18 / 10

dimes = 1

Now the remaining is computed as:

   change = change % 10;

This becomes:

   change = 18 % 10

  change = 8

Next the nickels are computed from remaining value of change as:

nickels = change / 5;

nickels = 8 / 5

nickels = 1

Now the remaining is computed as:

   change = change % 5;

This becomes:

   change = 8 % 5

  change = 3

At last the pennies are computed as:

pennies = change;

pennies = 3

So the output of the entire program is:

Change Owed: 0.43                                                                                                                Quarters: 1                                                                                                                      Dimes: 1                                                                                                                         Nickels: 1                                                                                                                       Pennies: 3  

The screenshot of the output is attached.

7 0
3 years ago
(Business: check ISBN-10) An ISBN-10 (International Standard Book Number) consists of 10 digits: d1d2d3d4d5d6d7d8d9d10. The last
Aneli [31]

Answer:

 The solution code is written in Python 3

  1. digits = input("Enter 9 digits: ")
  2. multiplier = 1
  3. total = 0
  4. for x in digits:
  5.    total += int(x) * multiplier  
  6.    multiplier += 1
  7. checksum = total % 11  
  8. if(checksum == 10):
  9.    print(digits + "X")
  10. else:
  11.    print(digits + str(checksum))

Explanation:

Firstly, use input function to get user input for 9 digits (Line 1)

Next we can use a for-loop to estimate the summation (d1 * 1 + d2 * 2 + d3 * 3 + d4 * 4 + d5 * 5+ d6 * 6 + d7 * 7 + d8 * 8 + d9 * 9) ( Line 6-8)

Then only apply % operator to get the remainder of total and get the checksum (Line 10)

Next create if and else statement to print the digits string joined with X if checksum is 10 else join digits string with checksum value (Line 12 -15)

7 0
4 years ago
Which team won the first World Series ?
Ulleksa [173]
Boston Red Sox, Boyo
5 0
4 years ago
Read 2 more answers
Circuitry can be either basic or ___________.
Sonja [21]
I think it would be A. Ohm's law.
hope this helps.
6 0
3 years ago
Read 2 more answers
Other questions:
  • After an informative session, you find yourself with several pages of notes. For maximum retention and understanding, you should
    6·1 answer
  • A risk handling technique in which the organization chooses to simply do nothing, as the cost of the risk being actualized is lo
    15·1 answer
  • Just forgot where she saved a certain file on her computer therefore she searched for all files with jpg file extension which ty
    13·2 answers
  • Many computer magazines and Web sites present comparisons of several DBMSs. Find one such DBMS comparison article and compare th
    10·1 answer
  • This loop is a good choice when you know how many times you want the loop to iterate in advance of entering the loop.
    14·2 answers
  • If(moreDate == true)
    7·1 answer
  • Help me find the difference between these logos
    10·2 answers
  • In an information systems framework, ________ is the bridge between the computer side on the left and the human side on the righ
    14·1 answer
  • Explica el empleo de cuentas y contraseñas en archivos
    6·1 answer
  • A write the result P*=++j where j is 24
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!