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
vlabodo [156]
2 years ago
10

For this exercise, you are going to complete the printScope() method in the Scope class. Then you will create a Scope object in

the ScopeTester and call the printScope.
The method will print the name of each variable in the Scope class, as well as its corresponding value. There are 5 total variables in the Scope class, some of which can be accessed directly as instance variable, others of which need to be accessed via their getter methods.
For any variable that can be accessed directly, use the variable name. Otherwise, use the getter method.
Sample Output:
The output of the printScope method should look like this:
a = 5
b = 10
c = 15
d = 20
e = 25
public class ScopeTester
{
public static void main(String[] args)
{
// Start here!
}
}
public class Scope
{
private int a;
private int b;
private int c;
public Scope(){
a = 5;
b = 10;
c = 15;
}
public void printScope(){
//Start here
}
public int getA() {
return a;
}
public int getB() {
return b;
}
public int getC() {
return c;
}
public int getD(){
int d = a + c;
return d;
}
public int getE() {
int e = b + c;
return e;
}
}
Computers and Technology
1 answer:
iragen [17]2 years ago
4 0

Answer:

Explanation:

The following is the entire running Java code for the requested program with the requested changes. This code runs perfectly without errors and outputs the exact Sample Output that is in the question...

public class ScopeTester

{

public static void main(String[] args)

{

       Scope scope = new Scope();

       scope.printScope();

}

}

public class Scope

{

private int a;

private int b;

private int c;

public Scope(){

a = 5;

b = 10;

c = 15;

}

public void printScope(){

       System.out.println("a = " + a);

       System.out.println("b = " + b);

       System.out.println("c = " + c);

       System.out.println("d = " + getD());

       System.out.println("e = " + getE());

}

public int getA() {

return a;

}

public int getB() {

return b;

}

public int getC() {

return c;

}

public int getD(){

int d = a + c;

return d;

}

public int getE() {

int e = b + c;

return e;

}

}

You might be interested in
Modify the CountByFives application so that the user enters the value to count by. Start each new line after 10 values have been
adoni [48]

Answer:

The modified program is as follows:

import java.util.*;

public class CountByAnything{  

public static void main (String args[]){

   Scanner input = new Scanner(System.in);

final int START = 5;

final int STOP = 500;

int countBy; int count = 0;

System.out.print("Count By: ");

countBy = input.nextInt();

final int NUMBER_PER_LINE = 10;

for(int i = START; i <= STOP; i += countBy){

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

count++;

if(count == NUMBER_PER_LINE){

System.out.println();

count = 0;} } } }

Explanation:

To solve this, we introduce two variables

(1) countBy --> This gets the difference between each value (instead of constant 5, as it is in the program)

(2) count --> This counts the numbers displayed on each line

The explanation is as follows:

<em>final int START = 5; </em>

<em>final int STOP = 500;</em>

This declares countBy and count. count is also initialized to 0

int countBy; int count = 0;

This prompts the user for countBy

System.out.print("Count By: ");

This gets value for countBy

countBy = input.nextInt();

<em>final int NUMBER_PER_LINE = 10;</em>

This iterates through START to STOP with an increment of countBy in between two consecutive values

for(int i = START; i <= STOP; i += countBy){

This prints each number

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

This counts the numbers on each line

count++;

If the count is 10

if(count == NUMBER_PER_LINE){

This prints a new line

System.out.println();

And then set count to 0

count = 0;}

6 0
3 years ago
What does the Additional Clock tab do?
BabaBlast [244]

Answer:

displays clocks in other time zones

Explanation:

it shows how time in other places in the world as well as yours

7 0
3 years ago
What are 25 items that trees made?
alexandr1967 [171]

Answer:

(things,can't think of more

.......)

  • paper
  • charcoal
  • doors
  • chairs
  • jewelry
  • wood frames
  • broom handles
  • furniture made with wood
6 0
3 years ago
Read 2 more answers
Consider the class ScopeTest defined this way:
Tasya [4]

Answer:

im working on this too but i think this is d

Explanation:

7 0
3 years ago
In QBasic, create a number guessing challenge. Your program should generate a random number from 1-
Sergio039 [100]

Answer:

yes

Explanation:

6 0
3 years ago
Other questions:
  • When a range of IP addresses is set aside for client devices, and one of these IPs is issued to these devices when they request
    14·1 answer
  • Which of the following button should always be included when designing a navigation pictures escape contact FAQ
    5·2 answers
  • Which type of computer network ensures high quality​
    9·1 answer
  • .in the array based list implementation of the ADT what is the worst case time efficiency of the remove method?
    6·1 answer
  • Users of Adobe Reader, created by Adobe Systems Incorporated, are prompted to provide feedback on their experiences with the sof
    7·1 answer
  • Indicate whether the statement is true or false. ____ 1. Autoglobal array elements are referred to with an index number. ____ 2.
    9·1 answer
  • A client calls to complain that his computer starts up, but crashes when Windows starts to load. After a brief set of questions,
    13·1 answer
  • Which is a concept of the CIA of Computer Security
    7·1 answer
  • Write a Python program to find whether a given number (accept from the user) is positive
    11·1 answer
  • PLS HELP SOON
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!