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
stellarik [79]
4 years ago
12

WRITE A JAVA PROGRAM TO PRINT THE PATTERN 13579 2468 357 46 5

Computers and Technology
1 answer:
Inessa05 [86]4 years ago
4 0

Answer:

import java.util.Scanner;

import java.lang.*;

class Main

{

  public static void main(String args[])

  {

     int n;

     //For capturing the value of n

     Scanner scanner = new Scanner(System.in);

     System.out.println("Enter the value of n:");

     //The entered value is stored in the var n

     n = scanner.nextInt();

     int k=1;

     printnum(n,k);  

  }

  public static void printnum(int n,int k)

  {

       if(n%2==0)

       {

       for(int i=k;i<=n-1;i=i+2)

            {

                System.out.print(i);

            }    

        System.out.println("");

       }

       else

        {

       for(int i=k;i<=n-1;i=i+2)

            {

                System.out.print(i);

            }    

        System.out.println("");

        }

      n--;

      if(n<=1)

      {

         System.exit(0);

      }

      else

      {

          printnum(n,k+1);

      }

   }

}

Explanation:

The program is self explanatory.

You might be interested in
Which tool will be useful in darkening a subject’s hair color in a photograph? A.Dodge tool B.Burn tool C.Patch tool D.Blur tool
choli [55]
It's B. The burn tool darkens stuff. The dodge tool lightens stuff. hope this helps, have an amazing day :)
8 0
4 years ago
Read 2 more answers
which button will allow you to insert quotes and notes into text into a document​ A comment B compare C research d margins
inysia [295]

Answer:

D margins

Explanation:

mark brainlist

3 0
3 years ago
GAMER OYUNCU KOLTUĞU % YERLİ
rewona [7]

Answer:

what does that even say omg

3 0
4 years ago
What is computer science​
adell [148]

Answer:

computer science is the study of computer and computing as well as theoretical and practical applications.

pls give me thanks ☺️☺️

7 0
3 years ago
If there is a slow internet connection or limited access to certain sites, it is often better to do what?
balu736 [363]

It is often better to check your connection and make sure it is secure.  Sometimes restarting the computer also works.  Hope this helped!

-TTL

4 0
3 years ago
Read 2 more answers
Other questions:
  • OSHA requires training for employees on the hazards to which they will be exposed.
    12·2 answers
  • Which tab is used to edit objects on the slide master and layouts
    10·1 answer
  • What information should you avoid sharing when updating your status?
    14·2 answers
  • What is the target audience for this poster?
    5·2 answers
  • Assume the existence of an UNSORTED ARRAY of n characters. You are to trace the CS111Sort algorithm (as described here) to reord
    14·1 answer
  • To protect yourself from the risk of product failure, what strategy could you use?
    15·1 answer
  • FRQ: Hotel Rooms Part A &amp; B Edhesive
    10·1 answer
  • Consider the code block below. What is the value of amount when this method is called twice, the first time using cookieJar(7) a
    14·1 answer
  • What is memory address map​
    7·1 answer
  • What was Bill Gates purpose for starting a business?
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!