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
Dima020 [189]
3 years ago
15

Write a method named hopscotch that accepts an integer parameter for a number of "hops" and prints a hopscotch board of that man

y hops. A "hop" is defined as the split into two numbers and then back together again into one. For example, hopscotch(3); should print ________.
Computers and Technology
1 answer:
Ivanshal [37]3 years ago
8 0

Answer:

Following are the program in the Java Programming Language.

public class Main // declared class  

{

public void hopscotch(int x) // function definition  

{

int count=0; // variable declaration  

for (int j=0; j<x; j++) // iterating over the loop

{

System.out.println(" " + (++count)); // print the value of count

System.out.println((++count) + " " + (++count));

}

System.out.println(" " + (++count));  

}

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

{

Main ob=new Main(); // creating object

ob.hopscotch(3); // calling hopscotch method  

}

}

<u>Output</u>:

  1

2     3

  4

5     6

  7

8     9

  10

Explanation:

Here, we define a class "Main" and inside the class, we define a function  "hopscotch()" and pass an integer type argument in its parentheses and inside the function.

  • We set an integer variable "count" and assign value to 0.
  • Set the for loop which starts from 0 and end at "x" then, print space and value inside the loop, again print value then space then value, then repeat the 1st print space then value.
  • Finally, set the main function "main()" and inside the main function, we create the object of the class "ob" then, call the function " hopscotch()" through the object and pass the value 3 in its parentheses.
You might be interested in
What are midi signals
gregori [183]

Answer: is a unified standard used when recording the sounds of instruments

3 0
3 years ago
Read 2 more answers
What did creator Markus “Notch" Persson initially call his game
Veronika [31]

Answer:

Cave Game

Explanation:

Its initial Name was to be game cave in the developer phase and later changed to minecraft order of the stone and later changed to minecraft

7 0
3 years ago
Read 2 more answers
Jason, Samantha, Ravi, Sheila, and Ankit are preparing for an upcoming marathon. Each day of the week, they run a certain number
kolbaska11 [484]

Answer:

C++ program explained below for the problem

Explanation:

// UpComingMarathon.cpp : Defines the entry point for the console application.

//header files

#include "stdafx.h" //optional

#include <iostream>

#include <cstring>

#include <fstream>

#include <iomanip>

using namespace std;

//declare the gobal array of type double

double average[5];

//declare the function prototypes

void getData(ifstream& inf, string n[], double runData[][8], int count);

void calculateAverage(double runData[][8], int count);

void print(string n[], double runData[][8], int count);

int main()

{

   string names[5];

   double runningData[5][8];

   ifstream inputfile("input.txt");

   if(inputfile)

   {

        //call the method getData

        getData(inputfile, names, runningData, 5);

   }

   else

   {

        //error message

        cout<<"Sorry! Unable to open the file."<<endl;

        system("pause");

        return 0;

   }

   //close the file

   inputfile.close();

   //call the method calculateAverage to compute the

   //average miliage of each runner

   calculateAverage(runningData, 5);

   //call display the names and their weekly run rate and their averages

   print(names, runningData, 5);

   system("pause");

   return 0;

}

//definition of method getData that reads the data from the file and

//stores the names into array n and run data into runData array

//simultaneously.

void getData(ifstream& inf, string n[], double runData[][8], int count)

{  

   while(!inf.eof())

   {

        for(int i=0;i<count; i++)

        {

            inf>>n[i];

            for(int j=0;j<7;j++)

            {

                inf>>runData[i][j];

            }

        }

   }

}

//definition of method calculateAverage that comptes the total first

//then stores the value of average into the average array

void calculateAverage(double runData[][8], int count)

{

   double total;

   for(int i=0;i<count;i++)

   {

        total=0;

        for(int j=0;j<7;j++)

        {

            total+=runData[i][j];

        }        

        average[i]=total/7;      

   }

}

//definition of method print that prints the output

//in a tabular format

void print(string n[], double runData[][8], int count)

{

   cout<<setfill('=')<<setw(80)<<"=";

   cout<<setfill(' ');

   cout<<endl;

   cout<<"Name"<<setw(6)<<"";

   for(int i=0;i<7;i++)

        cout<<setw(7)<<"Day "<<(i+1);

   cout<<setw(12)<<"Average"<<endl;

   cout<<setfill('=')<<setw(80)<<"=";

   cout<<setfill(' ')<<endl;

   for(int i=0;i<count;i++)

   {

        cout<<n[i]<<setw(8)<<fixed<<"";

        for(int j=0;j<7; j++)

        {

            cout<<setprecision(2)<<fixed<<runData[i][j]<<setw(3)<<"";

        }

        cout<<setw(8)<<average[i];

        cout<<endl;

   }

   cout<<setfill('=')<<setw(80)<<"=";

   cout<<endl;

}

5 0
3 years ago
What is the name of the computer that access shared resources on the network<br><br>​
tangare [24]

Answer:

what is the name of the computer that access shared resources on the network

5 0
3 years ago
Read 2 more answers
HOW DO I TURN THE CAPS LOCK OFF???? PLEASE HELP IT WONT STOP!!!!
svlad2 [7]

Answer:

Press the caps lock key

Explanation:

7 0
4 years ago
Read 2 more answers
Other questions:
  • Determine whether the relation represents a function. If it is a​ function, state the domain and range.
    6·1 answer
  • In the context of information systems, which of the following is a disadvantage of prototyping? a. A prototype is more difficult
    8·1 answer
  • Raul converts numbers in base 10 to base 2. Which answer best defends why Raul would need to do this?
    12·1 answer
  • What best describes a firewall
    11·1 answer
  • Hi Alaza, when you submit this form, the owner will be able to see
    12·1 answer
  • IfL = 4.4H and the inductive reactance of an inductor is 620 Omega find the frequency of the alternating current​
    5·1 answer
  • Consider the following first line from a Java method definition.
    13·1 answer
  • How to turn on a computer
    9·1 answer
  • 1. If we want define style for an unique element, then which css selector will
    14·1 answer
  • which server edition doesn't support any server roles that you would typically use with standard version
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!