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
bekas [8.4K]
3 years ago
6

Write a function called activity which takes an integer parameter X that does the following:

Computers and Technology
1 answer:
vodomira [7]3 years ago
8 0

Answer:

here is code in java.

import java.util.*;

class Main

{

//  main method of the class

public static void main (String[] args) throws java.lang.Exception

{

   try{

    // Scanner class object to read the input integer

       Scanner scr=new Scanner(System.in);

       // ask user to enter the input

       System.out.print("enter a number:");

       // read the input

       int x=scr.nextInt();

       // call the function with parameter "x"

       activity(x);

       

   }catch(Exception ex){

       return;}

}

// activity function to perform given tasks

public static void activity(int x)

{

    // print all the Numbers from 1 to x

    System.out.print("Numbers:");

    for(int i=1;i<=x;i++)

    {

        System.out.print(i+" ");

    }

     System.out.println();

    // print all the Evens from 1 to x

     System.out.print("Evens:");

     for(int i=1;i<=x;i++)

    {

        if(i%2==0)

        System.out.print(i+" ");

    }

     System.out.println();

     // replace divisible of 5 and 7 with "fiver" and "ssss"

     System.out.print("Activity:");

     for(int i=1;i<=x;i++)

    {

        if(i%5==0)

        System.out.print("fiver ");

        else if(i%7==0)

        System.out.print("ssss ");

        else

        System.out.print(i+" ");

    }    

}

}

Explanation:

Read an integer with the help of Scanner class object and assign it to variable "x". Call the function activity() with parameter "x". In the activity function, first print "Numbers" followed by all numbers from 1 to X. Then print header "Evens" followed by all the even number from 1 to x. In last print "Activity" header followed by numbers from 1 to x and replace a number with "fiver" if it is divisible by 5 or replace with "ssss" if it  divisible by 7.

Output:

enter a number:17                                                                                                          

Numbers:1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17                                                                          

Evens:2 4 6 8 10 12 14 16                                                                                                  

Activity:1 2 3 4 fiver 6 ssss 8 9 fiver 11 12 13 ssss fiver 16 17  

You might be interested in
Laurence Sims owns a football team that plays its home games in City Stadium. To increase revenue, he is offering a sponsorship
34kurt

Answer:$237,000

Explanation:

7 0
3 years ago
What is an accurate definition of a goal?
notka56 [123]

Answer:

something specific a person wants to achieve m8

Explanation:

5 0
3 years ago
Read 2 more answers
You have been employed as a technical consultant to a computer shop chain. You are given the task of creating a short consumer b
brilliants [131]

Answer:

The five factors to consider when trying to choose between a Solid State Drive, a Hard Disk Drive and, an External Hard Disk Drive are:

  1. Read/Write Speed
  2. Weight
  3. Power Consumption
  4. Cost
  5. Storage Capacity

  • Solid State Drives (SSDs) are typically lighter in weight, faster and do not consume much power.
  • Hard Disk Drives are relatively cheaper than SSDs. They also come with higher storage capacities but are more power-hungry and slower because they rely on mechanical/moving parts to read and write data.
  • External HDDs are the cheapest of the three. They are not internal which is a major drawback given the additional weight. However, they come with gargantuan storage capacities that make you want to rethink having one. Besides, unlike SSDs, you can easily get them in computer accessories shops offline or online.

Cheers!

3 0
3 years ago
Name the major types of computer systems from slowest to fastest. ​
Vadim26 [7]

Answer:

Cache is the fastest and most expensive, RAM is slower and less expensive, and virtual memory is the slowest and least expensive type.

Explanation:

3 0
2 years ago
What has global css rulesets of an angular 8 project mcq.
love history [14]

In order to conserve the angular momentum, Angular speed (w) often increases. The 'none of the above' option has global CSS rulesets of an angular 8 project mcq.

  • The angular momentum of a rigid object is known as the product of the moment of inertia and the angular velocity.

Angular speed is described as how quickly an object rotates. it is seen as the change in the angle of the object per unit of time.

See full question below

What has global CSS rulesets of an angular 8 project mcq.

A. e2e

B. None of the above

C. App

D. node_modules

Learn more from

brainly.com/question/24336703

7 0
2 years ago
Other questions:
  • You just read an msds for acetic acid. based on what you read, what type of information is included in an msds sheet? record you
    7·1 answer
  • When using a wireless mouse, what is the most common port used for the transmitter? 
    7·1 answer
  • How long does a baby dolphin stay with its mum
    8·1 answer
  • IT professionals recognize that successful systems must be user-oriented, and users need to be involved, formally or informally,
    11·1 answer
  • Services such as water, electricity, and phone communications are called:
    7·1 answer
  • Create a static method that: - is called appendPosSum - returns an ArrayList - takes one parameter: an ArrayList of Integers Thi
    6·1 answer
  • Explain the history of computing device of mechanical era
    7·1 answer
  • Can anyone please help me out
    10·1 answer
  • How long will the plant have been dead when 87.5 percent of its C-14 has become N-14?
    5·1 answer
  • Compare and contrast the leadership and leadership and management style of apple and Samsung ​
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!