Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Java Expert


Home >> Java

Text book: Java from control structures through objects edition 6

20658:
Write the definition of a method powerTo, which receives two parameters . The first is a double and the second is an int . The method returns adouble.

If the second parameter is negative, the method returns zero. Otherwise it returns the value of the first parameter raised to the power of the second parameter .

20574:
Write the code for invoking a method named sendNumber . There is one int argument for this method . Send the number 5 as an argument to this method.

Assume that sendNumber is defined in the same class that calls it.

20575:

Write the code for invoking a method named sendVariable. There is one int argument for this method .

Assume that an int variable called x has already been declared and initialized to some value . Use this variable 's value as an argument in yourmethod invocation.

Assume that sendVariable is defined in the same class that calls it.

20576:

Write the code for invoking a method named sendTwo. There are two arguments for this method : a double and an int . Invoke the method with the double value of 15.955 and the int value of 133.

Assume that sendTwo is defined in the same class that calls it.

20644:

printErrorDescription is a method that accepts one int argument and returns no value.

Write a statement that invokes the method printErrorDescription, passing it the value 14.

Assume that printErrorDescription is defined in the same class that calls it.

20645:

printLarger is a method that accepts two int arguments and returns no value.

Two int variables , sales1 and sales2, have already been declared and initialized .

Write a statement that calls printLarger, passing it sales1 and sales2.

Assume that printLarger is defined in the same class that calls it.

20646:

add is a method that accepts two int arguments and returns their sum.

Two int variables , euroSales and asiaSales, have already been declared and initialized . Another int variable , eurasiaSales, has already beendeclared.

Write a statement that calls add to compute the sum of euroSales and asiaSales and that stores this value in eurasiaSales.

Assume that add is defined in the same class that calls it.

20647:

toThePowerOf is a method that accepts two int arguments and returns the value of the first parameter raised to the power of the second.

An int variable cubeSide has already been declared and initialized . Another int variable , cubeVolume, has already been declared .

Write a statement that calls toThePowerOf to compute the value of cubeSide raised to the power of 3 and that stores this value in cubeVolume.

Assume that toThePowerOf is defined in the same class that calls it.

21155:

printStars is a method that accepts a single int argument and returns no value . It prints as many stars as indicated by its argument.
Given a variable x of type double that has been given a value , write a statement that invokes printStars passing x as an argument.

Assume that printStars is defined in the same class that calls it.

21017:

Given that a method receives three parameters a, b, c, of type double, write some code, to be included as part of the method, that determineswhether the value of "b squared" - 4ac is negative. If negative, the code prints out the message "no real solutions" and returns from the method

20604:

Write a method max that has two string parameters and returns the larger of the two.

20605:

Write a method min that has three string parameters and returns the smallest.

20840:

Write a method , makeSubjectLine, that gets a String argument and returns the same String but with "Subject: " in front of it. So if the argument is "Are you going to the show?" the method returns "Subject: Are you going to the show?".

20660:

Given the integer variables x, y, and z, write a fragment of code that assigns the smallest of x, y, and z to another integer variable min.
Assume that all the variables have already been declared and that x, y, and z have been assigned values .

21015:

Assume that x is a variable that has been declared as an int and been given a value . Assume that twice is a method (in the same class as the caller) that receives a single integer parameter and returns twice its value . (So if you pass 7 to twice it will return 14. Thus the expression twice(7) has the value 14.

Write an expression whose value is eight times that of x without using the standard Java arithmetic operators (*,+, etc.). Instead, use calls to twiceto accomplish this.

In this exercise you must write this as a single expression -- you must not write any statements . Also, you may only use the twice() function-- no other functions or operators .

21016:
Assume that x is a variable that has been declared as an int and been given a value . Assume that oneMore is a function that receives a singleinteger parameter and returns a value that is one greater than its argument . (So if you pass 7 to oneMore it will return 8. Thus, the expression oneMore(9) has the value 10.

Write an expression whose value is four more than x without using the standard Java arithmetic operators (*,+, etc.). Instead, use calls tooneMore to accomplish this.

In this exercise you must write this as a single expression -- you must not write any statements . Also, you may only use the oneMore function-- no other functions or operators .

20648:
max is a method that accepts two int arguments and returns the value of the larger one.

Two int variables , population1 and population2, have already been declared and initialized.

Write an expression (not a statement !) whose value is the larger of population1 and population2 by calling max.
Assume that max is defined in the same class that calls it.

20649:
max is a method that accepts two int arguments and returns the value of the larger one.

Four int variables , population1, population2, population3, and population4 have already been declared and initialized .

Write an expression (not a statement !) whose value is the largest of population1, population2, population3, and population4 by calling max.
Assume that max is defined in the same class that calls it.

21154:

The Math class provides a static method , max, that accepts two int arguments and returns the value of the larger one.

Four int variables , population1, population2, population3, and population4 have already been declared and initialized .

Write an expression (not a statement !) whose value is the largest of population1, population2, population3, and population4 by calling max.

21153:

The Math class provides a static method , max, that accepts two int arguments and returns the value of the larger one.

Two int variables ,population1 and population2, have already been declared and initialized .

Write an expression (not a statement !) whose value is the larger of population1 and population2 by calling max.

21014:

Assume that x is a variable that has been declared as a double and been given a value .

Write an expression to compute the quartic root of x. The quartic root of a number is the square root of its square root.

EXAMPLES: For example, the quartic root of 16.0 is 2.0 because: the square root of 16.0 is 4.0 and the square root of 4.0 is 2.0. Another example: the quartic root of 81.0 is 3.0 because the square root of 81.0 is 9.0 and the square root of 9.0 is 3.0. Thus, to find the quartic root of a number you take the square root of the number and then take the square root of that.

In this exercise you must find the quartic root of x in a single expression -- you must not write any statements . Also, you may only use the sqrt()static method defined in the Math class -- no other methods .

(HINT: you will need to call the Math.sqrt() method twice-- and you will need to pass the return value of one of those calls as argument to the other call. AND REMEMBER: write an expression , not a statement .)

73084:

A showChar Method

Write a method named showChar. The method should accept two arguments : a reference to a String object and an integer . The integer argument is a character position within the String , with the first character being at position 0. When the method executes, it should display the character at that character position. The method does not return anything.

Here is an example of a call to the method :

showChar("New York", 2);

In this call, the method will display the character w because it is in position 2. Demonstrate the method in a complete program .

73085:

Test Average and Grade

Write a program that asks the user to enter five test scores. The program should display a letter grade for each score and the average test score. Write the following methods in the program :

calcAverage:

This method should accept five test scores as arguments and return the average of the scores.

 

 

Java, Programming

  • Category:- Java
  • Reference No.:- M91783805
  • Price:- $110

Priced at Now at $110, Verified Solution

Have any Question?


Related Questions in Java

Assessment database and multithread programmingtasktask 1

Assessment: Database and Multithread Programming Task Task 1: Grade Processing University grading system maintains a database called "GradeProcessing" that contains number of tables to store, retrieve and manipulate stud ...

In relation to javaa what is constructor the purpose of

(In relation to Java) A. What is constructor? the purpose of default constructor? B. How do you get a copy of the object but not the reference of the object? C. What are static variables and instance variables? D. Compar ...

Project descriptionwrite a java program to traverse a

Project Description: Write a java program to traverse a directory structure (DirWalker.java) of csv files that contain csv files with customer info. A simple sample in provided in with the sample code but you MUST will r ...

Project requirementsfor the problem described in the next

Project requirements For the problem described in the next section, you must do the following: 1. include your student ID at the end of all filenames for all java code files. Three classes have been identified in section ...

Assessment socket programmingtaskwrite a java gui program

Assessment: Socket Programming Task Write a JAVA GUI program that would facilitate text chatting/exchanging between two or multiple computers over the network/internet, using the concept of JAVA socket programming. If yo ...

Chatbotscreate a small networked chat application that is

Chatbots Create a small, networked chat application that is populated by bots. Introduction On an old server park, filled with applications from the early days of the internet, a few servers still run one of the earliest ...

Simple order processing systemquestion given the classes

Simple Order Processing System Question: Given the classes Ship (with getter and setter), Speedboat, and SpeedboatTest. Answer the following questions: Refine the whole application (all classes) and create Abstract class ...

Operating systems assignment -problem 1 sharing the bridgea

Operating Systems Assignment - Problem 1: Sharing the Bridge A new single lane bridge is constructed to connect the North Island of New Zealand to the South Island of New Zealand. Farmers from each island use the bridge ...

Answer the following question whats the difference public

Answer the following Question : What's the difference public inheritance and private inheritance? What can derived classes inherit from base classes? What cannot be inherited from base classes?

Assessment instructionsin this assessment you will complete

Assessment Instructions In this assessment, you will complete the programming of two Java class methods in a console application that registers students for courses in a term of study. The application is written using th ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As