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;
}
}

Answers

Answer 1

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;

}

}


Related Questions

Why would an organization need to be aware of the responsibilities of hosting

personal data in its platforms?

Answers

Answer:

Providing transparent services for platform customers. Following data protection regulations to avoid disruptions from lack of compliance.

Computers were originally invented to
Group of answer choices
A.to share information on the Internet.

B.make complex mathematical calculations possible and make tasks easier for humans.

C.to play video games.

Answers

Answer:

B

Explanation:

It's B because why would it me made to play video games

Answer:

B

Explanation:

A, the internet didnt exist yet, so it cant be this

C, video games would require computers, so its ruled out on a similar basis as the previous

how to learn python ?

Answers

Answer:

See below.

Explanation:

To learn python programming language, first, you have to know the basic. Surely, you may recognize this function namely print()

print(“Hello, World!”) — output as Hello, World!

First, start with familiarizing yourself with basic function such as print. Then step up with arithmetic and declare or assign variable then list.

Here are example of functions:

1.) print(argument) — If argument is a string (word-typed), make sure to use “” or ‘’ or else it’ll output an error and say the argument is not defined.

print(“Hi, Brainly”) will output Hi, Brainly

print(2+3) will output 5

Numerical data or numbers do not necessarily require “ “ or ‘ ‘

print(3+3) will output 6 but print(“3+3”) will output 3+3 which is now a string.

2.) type(argument) - this tells you which data/argument it is. There are

< class ‘str’ > which is string, meaning it contains “ “ or ‘ ‘< class ‘int’ > which is integer< class ‘float’ > which is decimal (20.0 is also considered as float, basically anything that contains decimal is all float type)< class ‘list’ > which is a list. List is something that contains elements within square brackets [ ]

etc.

Make sure you also do print(type(argument)) as well so it will print out the output.

3.) Arithmetic

+ is addition

Ex. print(1+3) will output 4

   2. - is subtraction

Ex. print(5-4) will output 1

   3. * is multiply

Ex. print(4*5) will output 20

   4. ** is exponent

Ex. print(5**2) will output 25

   5. / is division

Ex. print(6/3) will output 2 — sometimes will output the float type 2.0

   6. % is modulo or remainder

Ex. print(7%2) will output 1

4.) Variables

To assign a variable, use =

An example is:

x = 2

y = 5

print(x+y) will output 7

print(type(x)) will output the < class ‘int’ >

These are examples of what you’ll learn in basic of python - remember, programming depends on experience and always focus on it. Keep practicing and searching will improve your skill at python.

User ideas for ro blox? I prefer no numbers or underscores.

Answers

do what the other person said

Assume in the for loop header, the range function has the three arguments: range (1, 10, 3), if you were to print out the value of the variable
in the for loop header, what will be printed out? List the values and separate them with a comma.

Answers

Answer:

1, 4, 7

Explanation:

The instruction in the question can be represented as:

for i in range(1,10,3):

   print i

What the above code does is that:

It starts printing the value of i from 1

Increment by 3

Then stop printing at 9 (i.e.. 10 - 1)

So: The sequence is as follows

Print 1

Add 3, to give 4

Print 4

Add 3, to give 7

Print 7

Add 3, to give 10 (10 > 10 - 1).

So, it stops execution.

Other Questions
Which of the following words is a preposition?A. preB. downC. loveD. quickly Plz, answer this question plz! what is the setting in the book powerless If a car has tires with a diameter of 28 inches and is traveling at 55 mph, how fast are its tires spinning, in rpm^ prime s (revolutions per minute)? [There are 63,360 inches in 1 mile) Round your final answer to 2 decimal places . An expression is shown.95-34What is the value of the expression? When a patient is seated upright, the thighs are ---blank--- to the abdomen. License plates in the tiny country of Venn follow a unique pattern. The first character is one of 41 Egyptian hieroglyphs, the second is one of 39 emojis, and the third character is one of 10 polygons. How many 3 character license plates are available to the people of Venn? What is the theme for the short film do geese see god created by Amazon Theater can someone help please what did john lewis like to do in college? HELP I NEED HELP ASAP HELP I NEED HELP ASAP HELP I NEED HELP ASAP HELP I NEED HELP ASAPHELP I NEED HELP ASAP HELP I NEED HELP ASAP HELP I NEED HELP ASAP HELP I NEED HELP ASAP .5% of what number is 15.8? Please answer the question above. 3/5-the square root of 5 Sheila works in the Arizona governor's office. How can she best paraphrase the content of the source? PLS HELPPP !! BRAINLIEST!! Each cube in this figure is a 1/2 -centimeter cube. What is the total volume of the prism? A. 4 1/2cm3B. 1 1/2cm3C. 6cm3D. 18cm3 how to learn python ? why we celebrate holi???? Explain or Show Work for how to solve 10 > 2x - 6. Give your solution as an inequality. * Can somebody just name all the metalloids, gases, and liquids that are on the periodic table. please this is due in a hour!!!