Sign in with
Sign up | Sign in
Your question

i cant write java code very well

Tags:
  • Programming
  • Java
  • Apps
Last response: in Apps General Discussion
Share
May 24, 2013 9:48:12 AM

hey! i have started a java program but i cant type the codes well. we started with declaring variables and now on inheritance but i cant figure out which code comes after which please help me.give me the steps how i can write short applications and know the codes and understand it very well.
Thanks .paul ghana

More about : write java code

May 24, 2013 9:58:18 AM

Java applications are anything but short. They are overly redundant and wordy. I'm not understanding your problem. Can you provide an example to a problem that you are having? I can't teach you the entire Java language in this thread.
m
0
l
May 24, 2013 11:46:45 AM

google "java tutorial"
m
0
l
Related resources
May 24, 2013 11:39:49 PM

codeacademy.com is a good website for learning to code.
m
0
l
May 24, 2013 11:47:06 PM

@Stealthinator: that's more web-related. For Java, codingbat.com is what I'd go with. :)  It still won't teach OP inheritance, which was OP's concern. Still waiting for OP to reply.
m
0
l
a b L Programming
May 25, 2013 3:22:36 AM

I think you should leave inheritance for a while and focus on more basic programming concepts. If a short (whatever that really means) application is what you are after, you probably won't need inheritance anyway.
m
0
l
May 27, 2013 5:56:46 AM

Thanks for your suggestions. i just want to understand how to declare a variable and declare a variable to hold 6 arrays
m
0
l
May 27, 2013 10:19:46 AM

  1. ArrayList<E> some_array = new ArrayList<E>();
  2. // E = type; so ArrayList<String> = Arrays of String.
  3. // You can have E = ArrayList for it to hold ArrayList instead
  4.  
  5. some_array.add(<SOME_ITEM_OF_TYPE_E>); // do this 6 times


That is as much as I can help with. Would be more useful to say what you're doing. Maybe using Arrays is not the best route.
m
0
l
May 28, 2013 1:57:57 AM

@Ksham thanks very much. can you send me your email address. this is the question i gave myself but i having chanllenges.
Itemcode Itemname Amount Quantity
C001 Rice 200.50 10
C002 Milk 10.35 100
C003 Cake 250.00 50
C004 Coke 15.00 24
C005 Milo 3.00 250

Declare 1 dimensional array for each column and use it to display the row of items by their code.
If you enter the item code, the item name, amount, and quantity should display.

Paul Agyapong
please help me.I was told that if i understand this, i will be able to tackle more java applications and even teach others.

randomizer said:
I think you should leave inheritance for a while and focus on more basic programming concepts. If a short (whatever that really means) application is what you are after, you probably won't need inheritance anyway.


10869550,0,1291079 said:
  1. ArrayList<E> some_array = new ArrayList<E>();
  2. // E = type; so ArrayList<String> = Arrays of String.
  3. // You can have E = ArrayList for it to hold ArrayList instead
  4.  
  5. some_array.add(<SOME_ITEM_OF_TYPE_E>); // do this 6 times


That is as much as I can help with. Would be more useful to say what you're doing. Maybe using Arrays is not the best route.[/quotemsg

m
0
l
May 28, 2013 2:26:33 AM

Should use a database. But anyway, it's along the lines of this. It can be written better, but I'm just lazy.

  1. // I'm representing the numbers as a String -- just laziness.
  2. // Again, can be designed better.
  3. Hashtable<String, Hashtable<String, String>> items = new Hashtable<String, Hashtable<String, String>>();
  4.  
  5. Hashtable<String, String> tmp = new Hashtable<String, String>();
  6. tmp.put("Itemname", "Rice");
  7. tmp.put("Amount", "200.50");
  8. tmp.put("Quantity", "10");
  9.  
  10. items.put('C001', tmp);
  11.  
  12. tmp.clear();
  13.  
  14. // keep going
m
0
l
May 31, 2013 9:51:26 AM

Hey i have this code to program a calculator but i can run it.help me
this is the code;


package calculator;
import java.util.Scanner;
/**
*
* @author Libertydmi
*/
public class TryCalcu {
public static void main(String[] args){
int a, b, answer;
String operator;
Scanner.s = new Scanner(System.in);

log("enter any maths equation using +, -, *, or /:");
a = s.nextInt();
operator = s.next();
b = s.nextInt();

if (operator.contains("+")){
answer = a + b;
log("" + answer);
}
if (operator.contains("-")){
answer = a - b;
log("" + answer);
}
if (operator.contains("*")){
answer = a * b;
log("" + answer);
}
if (operator.contains("/")){
answer = a / b;
log("" + answer);
}
}
public static void log(String get){
System.out.println(s);

}
}







ksham said:
  1. ArrayList<E> some_array = new ArrayList<E>();
  2. // E = type; so ArrayList<String> = Arrays of String.
  3. // You can have E = ArrayList for it to hold ArrayList instead
  4.  
  5. some_array.add(<SOME_ITEM_OF_TYPE_E>); // do this 6 times


That is as much as I can help with. Would be more useful to say what you're doing. Maybe using Arrays is not the best route.


m
0
l
May 31, 2013 10:57:13 AM

I don't see anything wrong with that code. What is your problem?
m
0
l
June 3, 2013 1:57:11 AM

The problem is this;
Cannot find symbol.The variable s location; class Scanner.
so the variable s is being underlined red. and due to that, it can't run the application.
Any suggestion on that.Thanks.




ksham said:
I don't see anything wrong with that code. What is your problem?


m
0
l
June 3, 2013 2:01:06 AM

Ah.

1. Replace the dot before the variable with a space.
2. The last println method should use the variable "get" and not "s".
m
0
l
June 3, 2013 2:40:20 AM

Thanks for the help.The red signs is off but if i want to run any equation, it gives an error. it cant.why?






ksham said:
Ah.

1. Replace the dot before the variable with a space.
2. The last println method should use the variable "get" and not "s".


m
0
l
June 3, 2013 2:48:12 AM

Tokens are per line. Read the javadoc. Programming will require a lot of reading of documentation. Get used to it. :) 
m
0
l
Related resources
!