method named product() to the Number() class that should compute the muliplication product of two integers but not display the answer.
Instead it should return the answer to the callimg method, which displays the answer...the "int product()" line you see below may not even supposed to be there..?
/*
Author: Kent Cox
Date:
Subject: Module 2 Homework, Chapter 3: EXC #2a
Purpose: Compute the sum and differance of two arguments and display their results.
//code//
*/
public class Numbers
{
public static void main(String[] args)
{
int numA = 9;
int numB = 7;
sum(numA, numB); //calls method to calculat sum
difference(numA, numB); //calls method to calculate diff
product(numA, numB);
}
public static void sum(int x, int y)
{
// Add the two arguments and display the results
System.out.println("The sum of " + x + " and " + y + " is " + (x+y) + ".");
}
public static void difference(int x, int y)
{
// Subtract the second argument from the first and display the results
System.out.println("The difference between " + x + " and " + y + " is " + (x-y) + ".");
}
public static int product(int x, int y){
return x * y;
}
System.out println("product" + x + "and" + y +);
}
=
//end code
Admin Edit: Please use code tags when posting your code. Code tags are used like so =>
Thanks,
PsychoCoder
This post has been edited by donitnavy: 15 March 2010 - 03:53 PM

New Topic/Question
Reply




MultiQuote









|