Siens Alot

Greenhorn
+ Follow
since Sep 13, 2015
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Siens Alot

Winston,

I understand that logic and i was think i need to put in another constructor but the few attempts i made failed and I have looked at a few you tube videos but got even more confused.
going to try and see if i can get that code edit to work so it is easier to see and I will also try to make a second constructor again thank you for the suggestion and any further help would be great trying to read straight from the book i bought is a bit confusing an I tried to find examples to explain plain but most seem to assume i already know java which as you can see i do not.


2nd Class




So can anyone give me an example of how i would right this 2nd constructor to collect the data from user input and not just the one i have working that gives the default constructor ham sandwich?


Thank you and Also thank you for the link on how to use the code feature much appreciated.

Siens66
8 years ago
is there a doc on how to use the code tags? I tried to use them but couldnt get them to work?
Siens66
8 years ago
Why am i not able to call manually enter data for firstSandwich? I am trying to call one object first sandwich form what is enter into the getData(Sandwich s( method and then have the secondSandwich call the data from the default constructor in Sandwich class.
I was unable to get the code to work in the editor so i attached me 2 class for review. And help or suggestion would be greaat as I am new to java and still trying to learn it.



8 years ago
So per your example I just call the other method from the main method. which i tried to do and got the non static error message. Also i am not sure about the .start(); after the call to the 2nd method?

8 years ago
Thank you all for the help and suggestions, question tho if i removed all the static from everything except the main method then i reeive the error below?
Interest.java:20: error: non-static variable salary cannot be referenced from a static context


how do i get the 2nd method to pull the variables if not static as I am missing something and they will not see each other?

I am greener then green and appreciate the help and suggestions.

Siens
8 years ago
that what i thought but if i move the varbiles before the 1st method to make them available to both classes I get the below error. How would i write this so both classes can use the same variables?

----jGRASP exec: javac -g Interest.java

Interest.java:20: error: non-static variable salary cannot be referenced from a static context
salary = input.nextDouble();
^
Interest.java:31: error: non-static variable earned cannot be referenced from a static context
earned = salary * rate;
^
Interest.java:31: error: non-static variable salary cannot be referenced from a static context
earned = salary * rate;
^
Interest.java:31: error: non-static variable rate cannot be referenced from a static context
earned = salary * rate;
^
Interest.java:32: error: incompatible types: missing return value
return;
^
Interest.java:34: error: non-static variable salary cannot be referenced from a static context
System.out.println("Interest earned on $" + salary + " at 5% would be $"+ earned );
^
Interest.java:34: error: non-static variable earned cannot be referenced from a static context
System.out.println("Interest earned on $" + salary + " at 5% would be $"+ earned );
^
7 errors

----jGRASP wedge2: exit code for process is 1.
----jGRASP: operation complete.
8 years ago
OK I am getting can't find symbol and i checked the spelling of varbiles but it seems my 2nd method is not seeing the variables and i can not figure this out. I am new to java coding and lost. I looked at the java website but nit sure where to look for the answer.

please help if you can.


errors:
----jGRASP exec: javac -g Interest.java

Interest.java:29: error: cannot find symbol
earned = salary * rate;
^
symbol: variable earned
location: class Interest
Interest.java:29: error: cannot find symbol
earned = salary * rate;
^
symbol: variable salary
location: class Interest
Interest.java:29: error: cannot find symbol
earned = salary * rate;
^
symbol: variable rate
location: class Interest
Interest.java:30: error: incompatible types: missing return value
return;
^
4 errors


thank you in advance
8 years ago
Aye the case is what got me thank you very much i didn't realize that.

I have used virtual Studio when i was messing around with c# ia there a program like that for java that uses intellisense?

the help is very appreciated.

thank you
Siens
8 years ago
Hello all and thank you for any help. I am greener then green as this is my first attempt to learn programming. I am receiving the below error on one of the examples in my test book and this is not a homework assignment. I have rewritten the code a few times and can not see what i am doing incorrectly. Any help would be greatly appreciated.

----jGRASP exec: javac -g CreateSpaServices.java

CreateSpaServices.java:15: error: cannot find symbol
service = keyboard.nextline();
^
symbol: method nextline()
location: variable keyboard of type Scanner
CreateSpaServices.java:24: error: cannot find symbol
keyboard.nextline();
^
symbol: method nextline()
location: variable keyboard of type Scanner
CreateSpaServices.java:26: error: cannot find symbol
service = keyboard.nextline();
^
symbol: method nextline()
location: variable keyboard of type Scanner
3 errors

----jGRASP wedge2: exit code for process is 1.
----jGRASP: operation complete.



The first class with out the main and is called by the second class follows:

The second Class with the main follows and i get the errors when i try and compile it. I thought it was do to me not importing the Scanner util but that part looks correct?


Thank you for any help you can provide.
on a side note is there a better program then jgrasp to use to code that uses intellisense?


Siens66



8 years ago