Access Millions of academic & study documents

3 a Create an application named ArithmeticMethods whose main() me

Content type
User Generated
Showing Page:
1/4
3.
a. Create an application named ArithmeticMethods whose
main() method holdstwo integer variables. Assign values to
the variables. In turn, pass each value tomethods named
displayNumberPlus10() , displayNumberPlus100() , and
displayNumberPlus1000() . Create each method to perform
the task its nameimplies. Save the application as
ArithmeticMethods.java .
b. Modify the ArithmeticMethods class to accept the values
of the two integers froma user at the keyboard. Save the
file as ArithmeticMethods2.java . Copyright | CENGAGE
Learning | Java Programming | Edition 7 |
christopher.campbell03@email.saintleo.edu | Printed from
www.chegg.com
Solution
Please find the required solution:
a)
public class ArithmeticMethods {
public static void main( String[] args )
{
//declare two integer variables
int a, b;
//Assign values to variables
a = 45;

Sign up to view the full document!

lock_open Sign Up
Showing Page:
2/4
b = 99;
//pass each value to methods named
displayNumberPlus10(a);
displayNumberPlus100(a);
displayNumberPlus1000(a);
displayNumberPlus10(b);
displayNumberPlus100(b);
displayNumberPlus1000(b);
}
//Create each method to perform the task its name
implies
public static void displayNumberPlus10( int num )
{
System.out.println(num + 10);
}
public static void displayNumberPlus100( int num )
{
System.out.println(num + 100);
}
public static void displayNumberPlus1000( int num )
{
System.out.println(num + 1000);
}
}
B)

Sign up to view the full document!

lock_open Sign Up
Showing Page:
3/4

Sign up to view the full document!

lock_open Sign Up
End of Preview - Want to read all 4 pages?
Access Now
Unformatted Attachment Preview
3. a. Create an application named ArithmeticMethods whose main() method holdstwo integer variables. Assign values to the variables. In turn, pass each value tomethods named displayNumberPlus10() , displayNumberPlus100() , and displayNumberPlus1000() . Create each method to perform the task its nameimplies. Save the application as ArithmeticMethods.java . b. Modify the ArithmeticMethods class to accept the values of the two integers froma user at the keyboard. Save the file as ArithmeticMethods2.java . Copyright | CENGAGE Learning | Java Programming | Edition 7 | christopher.campbell03@email.saintleo.edu | Printed from www.chegg.com Solution Please find the required solution: a) public class ArithmeticMethods { public static void main( String[] args ) { //declare two integer variables int a, b; //Assign values to variables a = 45; b = 99; //pass each value to methods named displayNumberPlus10(a); displayNumberPlus100(a); displayNumberPlus1000(a); displayNumberPlus10(b); displayNumberPlus100(b); displayNumberPlus1000(b); } //Create each method to perform the task its name implies public static void displayNumberPlus10( int num ) { System.out.println(num + 10); } public static voi ...
Purchase document to see full attachment
User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.
Studypool
4.7
Indeed
4.5
Sitejabber
4.4