Below is my program and my major problem, (I'm sorry in advance for it being so ugly I'm a pretty big noob and this is my first time using if, else if, else statements). My major problem is that when I go to compile this I get the same 4 errors, here are the errors: - *******************************************************************************
-
C:\Users\Susan\Desktop\Compsci\Compsci172\Assign 2\Phonebill.java:76: incomparable types: java.lang.String and int
-
if (Type == 1){
-
^
-
C:\Users\Susan\Desktop\Compsci\Compsci172\Assign 2\Phonebill.java:80: incompatible types
-
found : int
-
required: java.lang.Double
-
Amount2 = 0;
-
^
-
C:\Users\Susan\Desktop\Compsci\Compsci172\Assign 2\Phonebill.java:84: incompatible types
-
found : int
-
required: java.lang.Double
-
Amount2 = 0;
-
^
-
C:\Users\Susan\Desktop\Compsci\Compsci172\Assign 2\Phonebill.java:90: incomparable types: java.lang.String and int
-
else if (Type == 2){
-
^
-
4 errors
-
-
Tool completed with exit code 1
-
**********************************************************************************
-
I just need someone to tell me what it means when it says "incomparable types: java.lang.String and int" or "incompatible types found : int required: java.lang.Double" and how I can solve this to help fix my program. Thank anyone who's willing to help me, thank you so much!!! 6 3873
For the double to int conversion, you can cast it like so:
Amount2 = 0D;
or
Amount2 = (double)0;
For the strings to int, you would probably have to use the .Equals(Object) function, and/or cast the number to a string. eg:
if(Type.Equals("1"))
What program are you using to compile?
I'm using Textpad with the Java SE Runtime 6 External Application, thank you though!!! I'm going to give this try right now!
All right, the "Amount2 = (double)0" worked perfectly, thank you! I tried using the "if(Type.Equals("1"))" line though, I replaced the lines "if (Type == 1)" and "if (Type == 2)" and now when I try to compile it says:
cannot find symbol
symbol : method Equals(java.lang.String)
location: class java.lang.String
if(Type.Equals("1")){
cannot find symbol
symbol : method Equals(java.lang.String)
location: class java.lang.String
else if(Type.Equals("2")){
Am I entering that in the right spot?
Okay, the only things left that I need to fix are: 79: cannot find symbol
symbol : method Equals(java.lang.String)
location: class java.lang.String
if(Type.Equals("1")){
and: 93: cannot find symbol
symbol : method Equals(java.lang.String)
location: class java.lang.String
else if(Type.Equals("2")){
The rest of the code is still the same; anybody else have any help or suggestions?
In Java methods start with a lowercase letter, so it's 'equals', not 'Equals'. Read this article for a rationale of the conventions.
kind regards,
Jos
yes, lowercase equals. Sorry, C# kicked in for some reason.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: John Doe |
last post by:
Does anyone understand what a 'raw device number' is with respect
os.major() and os.minor()
Found in os-file-dir.html, section 6.1.4, os.major() description is:
major(device)
Extracts a...
|
by: Oliver Elphick |
last post by:
The attached proposal is written primarily for Debian. Its
motivation is that the current package upgrade process is pretty flaky
and also that the current packaging does not really provide for...
|
by: Tim Frawley |
last post by:
I have converted a VB6 application to VB.NET. The old application
made extensive use of the Clipboard for copying an Image Name so that
it could be pasted into the image capture app when the user...
|
by: Madison Kelly |
last post by:
Hi all,
I am new to the list and I didn't want to seem rude at all so I
wanted to ask if this was okay first.
I have a program I have written in perl which uses a postgresSQL
database as the...
|
by: Jef Driesen |
last post by:
I'm working on a project where i need to exchange multidimensional data
between C/C++ (row-major) and matlab (column-major). I understand the
difference between those two mappings to linear memory....
|
by: zdenko |
last post by:
I have a multi user database and users were created by user level security
wizzard - as I mentioned in message before. Everything works fine for those
users, but now I have another problem. I have...
|
by: Diwa |
last post by:
Hi Guys,
Is there any better way than below to find an int in a string (e.g.
"30" in "KFStat30A")
// --------------------------------------------------------------
#include <iostream>...
|
by: wketchin |
last post by:
Hey guys, this is my first time posting to this forum. I hope you're nice :D I love advice, and a solution would be even better!
So here's my situation:
I am building a website for the machine...
|
by: Lax |
last post by:
Isn't it "technically" meaningless to call C a "row major language,"
since there are no such things as multidimensional arrays in C.
In C you can define arrays of arrays, and the way that the...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
| | |