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
Go to your Canvas course and locate the Assignment: Writing Prompt 1: Is the Internet making us Meaner?and complete the activity
Maslowich

Answer and Explanation:

The Internet is not changing anything other than making you extreme. The nice become nicer, the mean become meaner, the nice become mean, and the mean become nice. The internet just makes things easier to do. It really isn't a factor in if you are mean or not.

7 0
3 years ago
Read 2 more answers
When should you use an electronic spreadsheet
nadezda [96]

Answer:

An electronic spreadsheet can be used to perform numerical calculations automatically

Explanation:

An electronic spreadsheet can be used to perform numerical calculations automatically. This spreadsheets are set up in the form of a table with rows and columns.

Data is stored in a cell formed as a result of intersection of each row and column.

Their primary purpose is to organize and categorize data into a logical format. This data then can be used to organize and grow the business.

6 0
3 years ago
Write a program that prompts the user for input and allows all of these member data values to be specified. The program should c
erma4kov [3.2K]

Answer:

The program to this question can be defined as follows:

Program:

#include <iostream> //defining header file

using namespace std;

struct MovieData  //defining structure MovieData

{

//defining structure variables

string Title; //defining string variable

int Year; //defining integer variable

string Timing; //defining string variable

};

void displayMovie(MovieData M_data) //defining method displayMovie

{

//print values

cout << "Title: "<<M_data.Title<<endl;

cout << "year: "<<M_data.year<<endl;

cout << "Timing: "<<M_data.Timing<<endl;

}

int main () //defining main method

{

MovieData z1,z2; //creating structure variables

cout<<"\t \t Enter First Movie Details:"<<endl; //message

cout << "Enter Title: ";//message

cin>>z1.Title; //input value

cout << "Enter Year: "; //message

cin>>z1.Year; //input value

cout << "Enter Timing: "; //message

cin>>z1.Timing;//input value

cout<<"\t \t Enter Second Movie Details: "<<endl;

cout << "Enter Title: "; //message

cin>>z2.Title;//input value

cout << "Enter Year: "; //message

cin>>z2.Year;//input value

cout << "Enter Timing: "; //message

cin>>z2.Timing;//input value

cout<<"\t\t Movies Detail:"<<endl; //message

displayMovie(z1); //calling a method

displayMovie(z2); //calling a method

return 0;

}

Output:

   Enter First Movie Details:

Enter Title: DDLJ

Enter Year: 2004

Enter Timing: 9to12am

   Enter Second Movie Details:  

Enter Title: RRR

Enter Year: 2010

Enter Timing: 12to3am

  Movies Detail:

Title: DDLJ

Year: 2004

Timing: 9to12am

Title: RRR

Year: 2010

Timing: 12to3am

Explanation:

In the above program a structure "MovieData" is defined, which is used to collect different type of values, inside the structure three variable "Title, Year, and Timing" is declared, in which "Title and Timing" is a string variable and Year is an integer variable.

  • In the next step, a method "displayMovie" is defined, in which we pass a structure object, which is "M_data", that prints the structure details.
  • In the main method two structure variable "z1, and z2" is declared, which take input in the structure variable and call the displayMovie method.
3 0
3 years ago
The way a student prepares for a test or reviews academic material is referred to as
ahrayia [7]

Answer:

study habits

Explanation:

3 0
3 years ago
Read 2 more answers
Given the following function definition
nasty-shy [4]

Answer:

The output of the given question is the option "B".

Explanation:

In the given code the output is the option B which is 1 6 3. Because in the function calc() we pass the two parameters and in this function we define an integer variable c that calculate the value of the variable a and b. in outside the function we declare three variable x,y and z in this we assign value that is 1,2,3 and call the function and print the value. The variable z is no pass in the function so the value of this variable is 3, x variable value is 1 and y variable value is 6. So the output of the code is 1 6 3.

7 0
3 years ago
Other questions:
  • They predicted another cold day in Seattle. They predicted another windy day in Seattle. Combine the sentences into one sentence
    8·1 answer
  • An EEG measures the electrical output of the brain by using sensors that are attached to someone's hands and feet. Please select
    15·2 answers
  • Function templates ___________.
    5·1 answer
  • What is an administrator?
    8·1 answer
  • In terms of online safety, what is the grooming process, (predators).
    5·2 answers
  • How do you feel about your self as a responsive citizen?​
    7·1 answer
  • A startup company is using an excel spreadsheet to keep track of the billable hours that each employee spends on a project. As y
    12·1 answer
  • Write a for loop to print all NUM_VALS elements of array hourlyTemp. Separate elements with a comma and space. Ex: If hourlyTemp
    11·1 answer
  • A new systems development project is Pete’s first experience as a project manager, and he has led his team successfully to the p
    13·1 answer
  • What type of pointing device is often used by artists, and why is it ideal for artists?​
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!