Results 1 to 3 of 3
Thread: use a class
- 04-06-2011, 08:59 AM #1
Member
- Join Date
- Apr 2011
- Posts
- 1
- Rep Power
- 0
use a class
Hello
Im beginner to java.
I made a simple class with customers and for every customer 3 sums to be seized,
it puts me an error of incompatible type (line 17) when I try to read to the keyboard, I don't understand why.
thank you
Java Code:import java.util.Scanner; class Compte{ String Nom; double Somme[]; } public class Module2_Exo1{ public static void main(String[]args){ Scanner sc = new Scanner(System.in); Compte[]tabCompte=new Compte[5]; Compte[]tabSomme=new Compte[3]; for (int i=0;i<tabCompte.length;i++){ tabCompte[i]=new Compte(); System.out.print("saisir nom Client" +( i+1) + " : "); tabCompte[i].Nom=sc.nextLine(); for (int j=0;j<tabSomme.length;j++){ tabSomme[j]=sc.nextDouble(); System.out.print("saisir Somme de " +(j+1) + " : "); sc.nextLine(); } } } }
- 04-06-2011, 09:17 AM #2
- Join Date
- Jan 2011
- Location
- Richmond, Virginia
- Posts
- 3,069
- Blog Entries
- 3
- Rep Power
- 7
Paste the exact error message please.
- 04-06-2011, 09:26 AM #3
Senior Member
- Join Date
- Apr 2010
- Location
- Dhaka,Bangladesh
- Posts
- 178
- Rep Power
- 0
tabsome is a object of Compte class and there are two variavle.they are Nom and Sommy.Compte[]tabSomme=new Compte[3];
What are you trying by this?
In which variable this Double value will be assigned?tabSomme[j]=sc.nextDouble();
Did you got it?
Create an constructor on the Compte class which will take one Double parameter which will assign the value as you wish.
Regards
UjjalDon't Forget to try yourself before asking others help.....
Press REP, if you find their advices/solutions effective.
Similar Threads
-
Eclipse Compile Error: Call validateValue(Class<T>, String, Object, Class<?>...)
By Tomshi in forum EclipseReplies: 0Last Post: 03-27-2011, 05:49 AM -
super class reference variable accesses overriding sub class method
By subith86 in forum New To JavaReplies: 5Last Post: 01-26-2011, 06:38 PM -
Dynamic loading of a class (passing class definition over the network)
By eddie-w in forum Advanced JavaReplies: 8Last Post: 04-14-2010, 05:49 AM -
[SOLVED] How to pass information from child class to parent class
By pellebye in forum New To JavaReplies: 7Last Post: 05-06-2009, 12:42 PM -
problem in accessing array values of one class in to jframe class
By cenafu in forum AWT / SwingReplies: 8Last Post: 03-21-2009, 09:34 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks