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
sesenic [268]
3 years ago
12

Java public class Odds { public static void main(String[] args) { printOdds(3); printOdds(17/2); int x = 25; printOdds(37 – x +1

); } public static void printOdds(int n) { for (int i = 1; i <= n; i++) { int odd = 2*i -1; System.out.print(odd + " "); } System.out.println(); } }
Write the output.
Computers and Technology
1 answer:
Serggg [28]3 years ago
5 0

Answer:

The output of the given program is :

1 3 5

1 3 5 7 9 11 13 15

1 3 5 7 9 11 13 15 17 19 21 23 25

Explanation:

The description of the following program can be given as:

  • In the given java program firstly we define a class that is "Odds". In this class, we define the main method. In this method, we call printOdds() function three times.  
  • In the first time calling, we pass 3 in the function parameter. So the function print 3 odd number that is 1 3 5.
  • In the second time calling, we pass value 17/2 in function parameter which is 8. So, the function print 8 odd number that is 1 3 5 7.....15
  • In third time calling we define an integer variable that is x in this variable we assign value that is 25 and call function that calculates value (37-x+1) that is 13. So, the function print 13 odd numbers that is 1 3 5 7..........25.
  • In the last, we define the printOdds() function that is outside the class that prints odd numbers.
You might be interested in
Mad Libs are activities that have a person provide various words, which are then used to complete a short story in unexpected (a
Marina86 [1]

Answer:

I am writing a C++ and JAVA program.    

import java.util.Scanner; //for using input output functions

public class LabProgram { // class name

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

Scanner input = new Scanner(System.in);

// creates input instance of  Scanner type

     String str;  // declares String type variable str for a string value

     int num;  // declares integer type variable num to hold an integer value

     str = input.next(); //scans and reads input string from user

     num = input.nextInt();  //scans and reads input integer from user

//while loop continues to execute until user enters quit 0

while(str!="quit" && num!=0) {  

/* prints the following message, for example if value of num = 2 and value of str = apples then the following print statement prints Eating 2 apples a day keeps the doctor away. */

System.out.println("\nEating " + num +" " + str + " a day keeps the doctor away.");

//takes string and integer as input again and keep taking input until user //enters quit 0

str = input.next();  

num = input.nextInt(); }   } }

Explanation:

The program is well explained in the comments mentioned with each statement of the program. The program simply prompts user to enter a string and an integer. The while loop keeps executing until user enters quit 0. The program keeps taking input string and integer from user and prints the message System.out.println("\nEating " + num +" " + str + " a day keeps the doctor away.");  The loop breaks when the use enters quit 0. The screenshot of the program along with its output is attached.

3 0
3 years ago
If nobody buys a ticket to a movie, do they still show it?
Serga [27]

It would depend on the movie and the theater policy.....

Hope this helps have a good day

3 0
3 years ago
How would you create a tint of a color?
svetlana [45]
D. white with a hue
HOPE THIS HELPS
5 0
3 years ago
PLEASE HURRY
creativ13 [48]
I'm pretty sure it's C) or D) because it seems those make the most sense because providing excitement does not matter if that is not their point, repeating a previous point is practically useless because that point has already been said.
5 0
3 years ago
Read 2 more answers
What sentence could Lou’s granddaughter not answer? Explain the context and discuss whether you could answer this question or no
Tanya [424]
He wouldn’t answer the context for the discussion
7 0
2 years ago
Other questions:
  • According to your textbook, which of the following is a consequence of the quick development of new technologies in the digital
    8·1 answer
  • What are the 5 general terms of the fair use rule
    9·1 answer
  • The two types of objects responsible for collecting data are
    14·1 answer
  • Which term is used to describe a password-protected, encrypted data file that verifies the identity of the sender of a message?
    8·1 answer
  • Nate wants to copy the style of his contact address to the normal template. Complete the paragraph to describe how he can access
    6·1 answer
  • You are driving on expressway with three lanes in your direction at a speed lower then
    8·2 answers
  • You are between flights at the airport and you want to check your email. Your wireless settings show two options:
    14·1 answer
  • Differentiate between perfect and imperfect market​
    14·1 answer
  • It is a data being transported on a network​
    13·1 answer
  • What is the difference between a computer’s RAM and its hard disk?
    13·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!