Vince Travis Sillhouette Angeles
Create a myMath class that contains the ff procedures and or methods
1. Add any number of numbers
2. Multiply any number of numbers
3. Raise a number to the nth power
4. Slope of a line given 2 points
5. Factors of a whole number
6. Acceleration of an object given any number of velocities
7. Density of an object given its mass and weight
8. Force in Newton's given mass and acceleration
9. Determine if a number is even
10. Determine if a number is prime
* put your own comments on the code
* use appropriate naming conventions
* use appropriate return type and return value
* use appropriate parameter list

...if someone can program this... thanks a lot..
and merry christmas

What questions do you have about writing this code?
Do you have problems, please post them.

Lots of us here CAN. It doesn't mean that we WILL!
I have my own projects to work on.
Besides... I have to do some baking this weekend.
Those "Christmas Pies" won't make themselves!!

Edited 4 Years Ago by hfx642: n/a

Create a myMath class that contains the ff procedures and or methods:
1. Add any number of numbers
2. Multiply any number of numbers
3. Raise a number to the nth power
4. Slope of a line given 2 points
5. Factors of a whole number
6. Acceleration of an object given any number of velocities
7. Density of an object given its mass and weight
8. Force in Newton's given mass and acceleration
9. Determine if a number is even
10. Determine if a number is prime
* put your own comments on the code
* use appropriate naming conventions
* use appropriate return type and return value
* use appropriate parameter list

...if someone can program this... thanks a lot..
and merry christmas...

I Programmed This using NetBeans IDE but I dont Know How To Program The Others ...
I only Program what i know...
Heres my Program:
Kindly Check and Edit It if you have Time Thankzz...

public class myMath {
  public static void main(String[] args) {

  int sum = Add(5,3,2); 
  System.out.println("the sum is " +sum);

  int product = Multiply(4,3);
  System.out.println("the product is " +product);

  float slope = Slope(4,3,5,6);
  System.out.println("the slope is " +slope);

  int RaiseValue = raisenumber(2,6);
  System.out.println("the Raised Value is " +RaiseValue);

  String evenNum = Even(8);
  System.out.println(evenNum);
  }

  public static int Add(int...num){
  int sum=0;
  for(int number : num){
  sum = sum + number;}
  return sum;
  }

  public static int Multiply(int...num){
  int product=1;
  for (int number : num)
  product= product*number;
  return product;
  } 

  public static float Slope(float x1, float y1,float x2, float y2){
  float slope;
  slope=(y2-y1)/(x2-x1);
  return slope;
  }

  public static String Even(int num){
  String evenNum;
  if(num%2 == 0){
  evenNum="the number is Even";}
  else
  evenNum="the number is Odd";
  return evenNum;
  }

  public static int raisenumber(int num,int power){
  int RaiseValue=1;
  for(int x=1; x<=power; x++){
  RaiseValue=RaiseValue*num;}
  return RaiseValue;
  }
  }

Edited 4 Years Ago by peter_budo: Keep It Clear - Do use code tags when posting any code

yes, but what questions do you have except for: can anyone code my homework before I have to hand it in?

what's the code you tried that isn't working? what error messages do you get?

"If" he has no problem with the code he posted then the remaining problems he wants suggestions must be from numbers 10,8,7,6,5

5. Factors of a whole number
Divide the n number by numbers ranging from 1 to n using a modulo then check if the answer is equal to 0, if not then list down the number

6. Acceleration of an object given any number of velocities
Is time given?

7. Density of an object given its mass and weight
Convert weight to volume then divide mass from the volume

8. Force in Newton's given mass and acceleration
F=m*a... Is it that hard?

10. Determine if a number is prime
You need to check if the given number is not divisible by any number other than itself or 1 so divide the number ranging from 2 to the number before the given number using a modulo...if one of the answers is equal to 0 then its not a prime number

Edited 4 Years Ago by zeroliken: n/a

7.Density can't be calculated from mass and weight, weight= force by earth= mass * g, no way to get volume
5&10. Don't check for all numbers upto n, n/2 or sqrt(n) is enough right?

Edited 4 Years Ago by v3ga: n/a

This question has already been answered. Start a new discussion instead.