Write a program in Java that multiplies the column vector A [n] by
some number. The matrix and number are initiated by a random value generator.
--- Update ---
Please I really need help
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
Write a program in Java that multiplies the column vector A [n] by
some number. The matrix and number are initiated by a random value generator.
--- Update ---
Please I really need help
What have you tried?
Post your current code and any questions about it.
If you don't understand my answer, don't ignore it, ask a question.
First step is to understand what is to be done. Can you describe what steps the program needs to take to solve the problem?
What does a column vector A [n] look like? What is in it? Does it contain numbers? Are they integers or float?
Where does some number come from?
What is The matrix and number ? Where do they come from?
random value generator. See the Random class for methods that will generate random numbers.
If you don't understand my answer, don't ignore it, ask a question.
This thread is old enough that doing other people's homework no longer applies, so here's my version
import java.util.Random; public class Main{ public static void main(String[] args) { Random rng = new Random(); // random number generator // create a vector with ten random doubles in the range [0..1) double vector[] = new double[10]; // load vector with random values for( int index = 0; index < vector.length; index++){ vector[index] = rng.nextDouble(); } displayVector(vector); // random multiplier int in range [0..100) int multiplier = rng.nextInt(100); // multiply vector by scaling factor (multiplier) for( int index = 0; index < vector.length; index++){ vector[index] *= multiplier; } // display results System.out.println( String.format("scaled by a factor of %s", multiplier) ); displayVector(vector); } // main // display vector static void displayVector(double[] vector){ String output = "v[ "; for(double thisValue : vector){ output += String.format("%4.4f ", thisValue); } System.out.println(output + "]"); } // displayVector } // Main