Jump to content

anyone can tell me what im doing wrong?

Go to solution Solved by matin94,

Take a close look at System.out.println(answers); and the number of ints in courseworkmark.

Working for me when I fixed those two lines.

right this iswhat ive done and it worked

 

public class computemarks 
{
public static void main (String [] args)
{
System.out.println("Exam Mark" + "\t" + "Coursework" + "\t" + "Modulemark");
int marksexam [] = {50, 50, 50, 50, 50};
int courseworkmark [] = {50, 50, 50, 50, 50};
int answers [] = new int [marksexam.length];
for (int i = 0; i < answers.length; i++){
answers = marksexam + courseworkmark;
System.out.println(answers);
}
}
 
}
i added interger i in the print out code with answers
 i have 5 elements in each array. i need to add them up, and produce the results in a new array

what am i doing wrong or not doing at all

 

 import java.lang.*;

public class computemarks 

{

public static void main (String [] args)

{

System.out.println("Exam Mark" + "\t" + "Modulemark");

int marksexam [] = {50, 50, 50, 50, 50};

int courseworkmark [] = {50, 50, 50, 50};

int answers [] = new int [marksexam.length];

for (int i = 0; i < answers.length; i++){

answers = marksexam + courseworkmark;

System.out.println(answers);

}

}

 

}
Link to comment
Share on other sites

Link to post
Share on other sites

Take a close look at System.out.println(answers); and the number of ints in courseworkmark.

Working for me when I fixed those two lines.

Link to comment
Share on other sites

Link to post
Share on other sites

Take a close look at System.out.println(answers); and the number of ints in courseworkmark.

ill try it thanks

Link to comment
Share on other sites

Link to post
Share on other sites

Take a close look at System.out.println(answers); and the number of ints in courseworkmark.

Working for me when I fixed those two lines.

right this iswhat ive done and it worked

 

public class computemarks 
{
public static void main (String [] args)
{
System.out.println("Exam Mark" + "\t" + "Coursework" + "\t" + "Modulemark");
int marksexam [] = {50, 50, 50, 50, 50};
int courseworkmark [] = {50, 50, 50, 50, 50};
int answers [] = new int [marksexam.length];
for (int i = 0; i < answers.length; i++){
answers = marksexam + courseworkmark;
System.out.println(answers);
}
}
 
}
i added interger i in the print out code with answers
Link to comment
Share on other sites

Link to post
Share on other sites

 

right this iswhat ive done and it worked

 

public class computemarks 
{
public static void main (String [] args)
{
System.out.println("Exam Mark" + "\t" + "Coursework" + "\t" + "Modulemark");
int marksexam [] = {50, 50, 50, 50, 50};
int courseworkmark [] = {50, 50, 50, 50, 50};
int answers [] = new int [marksexam.length];
for (int i = 0; i < answers.length; i++){
answers = marksexam + courseworkmark;
System.out.println(answers);
}
}
 
}
i added interger i in the print out code with answers

 

This just goes to show that there is always an easier way to write code. The original code looked so confusing, I haven't learned Java but I've read some books on it and his code looked confusing, but your code looks so simple and I can look at it and know exactly why you put each line of code

There are 10 types of people in this world, those who understand binary, and those who don't.

Link to comment
Share on other sites

Link to post
Share on other sites

This just goes to show that there is always an easier way to write code. The original code looked so confusing, I haven't learned Java but I've read some books on it and his code looked confusing, but your code looks so simple and I can look at it and know exactly why you put each line of code

WOW man that means alot, got tears in my eyes haha :') thanks

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×