i cant write java code very well

Paul Agyapong

Honorable
May 24, 2013
7
0
10,510
0
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
 

ksham

Honorable
Mar 29, 2013
175
0
10,760
25
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.
 

ksham

Honorable
Mar 29, 2013
175
0
10,760
25
@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.
 

randomizer

Distinguished
Moderator
Jul 24, 2006
880
0
19,260
62
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.
 

ksham

Honorable
Mar 29, 2013
175
0
10,760
25
Code:
ArrayList<E> some_array = new ArrayList<E>();
// E = type; so ArrayList<String> = Arrays of String.
// You can have E = ArrayList for it to hold ArrayList instead

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.
 

Paul Agyapong

Honorable
May 24, 2013
7
0
10,510
0
@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.



 

ksham

Honorable
Mar 29, 2013
175
0
10,760
25
Should use a database. But anyway, it's along the lines of this. It can be written better, but I'm just lazy.

Code:
// I'm representing the numbers as a String -- just laziness.
// Again, can be designed better.
Hashtable<String, Hashtable<String, String>> items = new Hashtable<String, Hashtable<String, String>>();

Hashtable<String, String> tmp = new Hashtable<String, String>();
tmp.put("Itemname", "Rice");
tmp.put("Amount", "200.50");
tmp.put("Quantity", "10");

items.put('C001', tmp);

tmp.clear();

// keep going
 

Paul Agyapong

Honorable
May 24, 2013
7
0
10,510
0
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);

}
}









 

Paul Agyapong

Honorable
May 24, 2013
7
0
10,510
0
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.






 

Paul Agyapong

Honorable
May 24, 2013
7
0
10,510
0
Thanks for the help.The red signs is off but if i want to run any equation, it gives an error. it cant.why?








 
Thread starter Similar threads Forum Replies Date
M Apps General Discussion 5
M Apps General Discussion 2
H Apps General Discussion 3
A Apps General Discussion 1
Y Apps General Discussion 1
L Apps General Discussion 5
O Apps General Discussion 1
V Apps General Discussion 1
M Apps General Discussion 9
S Apps General Discussion 2
A Apps General Discussion 1
P Apps General Discussion 1
L Apps General Discussion 3
A Apps General Discussion 1
T Apps General Discussion 1
Y Apps General Discussion 1
I Apps General Discussion 2
C Apps General Discussion 3
K Apps General Discussion 4
A Apps General Discussion 6
Similar threads
Solved! re-write certain part of .mp4 file using ffmpeg
Write a menu driven program which has following options 1. Factorial 2. Prime or not 3. Odd or even. 4. Exit. Once the menu
Write a program in C++ using classes and function overloading, to calculate volume of Cube, Cuboid and a Cylinder, the program
Write a C program that computes and prints out an approximate number of primes not exceeding a given number, x .
Write a program to calculate commission for the input valu of sales amount
Could you please help me write a cpp code for an assignment I have in school for juice
how to write a calculator program that will ask the user if he/she wann continue using loop
Write basic statement of To add values of X and Y in Z
Does anyone know if there is software to write mkv files to an UHD blu ray?
online4. Write the program to declare Single dimensional array that stores (5) integer values and perform following operations
Write a program for a multiple choice survey.
1st question : 210 points. Write a program to simulate a keyboard with given keys and their operation. You need to print the f
I turned in an assignment late because MyWritingLab took awhile to process my temp access code
palindrome is a word, phrase, or sequence that reads the same backwards as forwards. Given a palindrome write a program to pri
Write a C++ program to help the Administration of a football league to manipulate the list of players registered in different
write a program to create a frame by creating an object to the subclass of an frame class
1. Write a program that outputs the greatest common divisor of two positive integers. For example, if you input two positive
How to remove write protect from photos already on computer
AutoHotKey Script writing for n00bs.
3. Write a C# application that asks the user to input ‘A’ and ‘B’ and prints the sum of squares of all even numbers be

ASK THE COMMUNITY