Get the answers you need at Westonci.ca, where our expert community is dedicated to providing you with accurate information. Discover a wealth of knowledge from experts across different disciplines on our comprehensive Q&A platform. Join our platform to connect with experts ready to provide precise answers to your questions in different areas.

public class NumberGames

{



// Keep track of the number

private double num;



// Constructor

public NumberGames(double startingNumber)

{

num = startingNumber;

}



// Returns the number

public double getNumber()

{

return num;

}



// Doubles the number

// Returns the doubled number

public double doubleNumber()

{

num *= 2;

return num;

}



// Squares the number

// Returns the squared number

public double squareNumber()

{

num *= num;

return num;

}





}







--------





public class GamesTester

{

public static void main(String[] args)

{

NumberGames game = new NumberGames(3);



// Double the number

// Print it out





// Square the number

// Print it out



// Double the number again

// Print it out



// Get the number and store the value

// Print it out to see that getNumber does

// not modify the number



}

} Exercise 2.6.6: Number Games w This class has a few methods for manipulating a number. The object has
been created for you. Call the methods indicated and print out the result of each method call. Your output
should look like this 6.0 36.0 72.0 72.0


Sagot :

Thank you for choosing our platform. We're dedicated to providing the best answers for all your questions. Visit us again. Thanks for using our platform. We aim to provide accurate and up-to-date answers to all your queries. Come back soon. Westonci.ca is committed to providing accurate answers. Come back soon for more trustworthy information.