473,387 Members | 2,436 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Scanner problems Easy for people who know Java (I dont!)- Need Immediate Help!!!

22
What is wrong with this?? Here are the two classes...SandBox and KittyKitty?? I need to also know what happens if two or more values are equal and if exactly two values are equal, does it matter whether the equal values are lower or higher than the third?? And can somebody please help me answer the questions at the bottom???

//A place to play with your kitty

public class SandBox
{
public static void main(String[] args)
{
Scanner scan = new Scanner(System.in);
KittyKitty cat = new KittyKitty();

/////////////////////////////////////////////////////////////
// This is where you put YOUR code to have "cat"
// call ( use ) the methods ( services ,function , procedures)
// YOU have defined ( written ) in the class called KittyKitty
/////////////////////////////////////////////////////////////

int able = 10;
int cdef = 5;
String ghi = "good";
cat.myMethod_1(able, cdef, ghi);
}//End main()

}//End class definition
__________________________________________________ ________________

public class KittyKitty {

{
/////////////////////////////////////////////////////////////
// Here is where you will write ( define ) the methods of
// this class
/////////////////////////////////////////////////////////////
public KittyKitty()
{
}//End constuctor

void myMethod_1( int able, int cdef, String ghi)
{
if( able < cdef)
{
System.out.println("The answer is=" + ghi);
}// End if
System.out.println("The answer is not=" + ghi);
}//End myMethod_1()
}//End class definition
__________________________________________________ ________________

What is wrong with this and how do I rewrite it to produce the correct output??

if (total == MAX)
if (total < sum)
System.out.println ("total == MAX and is < sum.");
else
System.out.println ("total is not equal to MAX");
__________________________________________________ ________________

Whats wrong with this and will it compile if it is part of an otherwise valid program? I'm supposed to explain

if (length = MIN_LENGTH)
System.out.println ("The length is minimal.");
Oct 15 '06 #1
4 1964
Let me give you an example of a Scanner Object below:

System.out.print("Type input: ");
Scanner reader=new Scanner(System.in);
String myText=reader.nextLine();
System.out.println("Your text is: "+myText);

This way you are I think able to adjust your code and make it work.
Oct 15 '06 #2
__________________________________________________ ________________

What is wrong with this and how do I rewrite it to produce the correct output??

if (total == MAX)
if (total < sum)
System.out.println ("total == MAX and is < sum.");
else
System.out.println ("total is not equal to MAX");
__________________________________________________ ________________

Whats wrong with this and will it compile if it is part of an otherwise valid program? I'm supposed to explain

if (length = MIN_LENGTH)
System.out.println ("The length is minimal.");[/quote]
----------------------------------------------------------------------------------------------
You have to be aware of WHAT you are comparing: Integers, doubles, Strings
etc.
To compare integers you can use == or != for resp. equal and not equal
The same thing with doubles. What you can't do is compare an integer and double. You will have to cast one of them to the other. Most likely you would want them both to become a double. if variable 'count' is an integer, you can cast it to a double like this: (double) count.

I'm not really sure what you want with your first code though.

your second if-statement:
you should compare again with ==, != , <, > , <=, >=

If you want more info, you should pass me the whole code, because otherwise I won't be sure if I can help you without it.
Oct 15 '06 #3
ryann18
22
__________________________________________________ ________________

What is wrong with this and how do I rewrite it to produce the correct output??

if (total == MAX)
if (total < sum)
System.out.println ("total == MAX and is < sum.");
else
System.out.println ("total is not equal to MAX");
__________________________________________________ ________________

Whats wrong with this and will it compile if it is part of an otherwise valid program? I'm supposed to explain

if (length = MIN_LENGTH)
System.out.println ("The length is minimal.");
----------------------------------------------------------------------------------------------
You have to be aware of WHAT you are comparing: Integers, doubles, Strings
etc.
To compare integers you can use == or != for resp. equal and not equal
The same thing with doubles. What you can't do is compare an integer and double. You will have to cast one of them to the other. Most likely you would want them both to become a double. if variable 'count' is an integer, you can cast it to a double like this: (double) count.

I'm not really sure what you want with your first code though.

your second if-statement:
you should compare again with ==, != , <, > , <=, >=

If you want more info, you should pass me the whole code, because otherwise I won't be sure if I can help you without it.[/quote]

The question is supposed to be used with the code I had, the KittyKitty and the Sandbox... I'm not sure what the crap to do???
Oct 15 '06 #4
=ryann18
The question is supposed to be used with the code I had, the KittyKitty and the Sandbox... I'm not sure what the crap to do???
I gave you the Scanner Code, because you definately need to chang that one.
Oct 16 '06 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: prash | last post by:
Hi everybody, I would like to request all the members to help me find the source code for the following : 1.C program for error detecting code: CRC-CCITT and CRC -32. 2.c Program for...
1
by: Abraham | last post by:
I want to design a system, for License regestration in MS Access and i will get it into the web by ASP.. what i want to know is how to make a notification that will be sent to a particular person...
4
by: semooo | last post by:
hi Im waseem I need an immediate help as soon as possible, I have three simple question with coding problems in data structure in c++ thess are : 1)suppose that you are finanicier and purchase...
9
by: Mickey Segal | last post by:
The long-simmering Eolas patent dispute: http://www.microsoft.com/presspass/press/2003/oct03/10-06EOLASPR.mspx has led to an optional Microsoft Update: http://support.microsoft.com/kb/912945/en-us...
5
by: rajasavi | last post by:
hi, i m rajasavi.have just studied learning VB.net and need some help .i m making small window application using database about getting verfiying password before entering the other page.but my...
0
by: alfie27 | last post by:
Hi, I am getting 2 errors when i try to run my program. This is my first time using the struct feature so i'm not sure how to correct my errors. Any help will be greatly appreciated. Here are the...
9
by: pic078 via AccessMonster.com | last post by:
I need serious help - I have a frontend/backend Access database (2 MDE Files) that remains stuck in task manager after exiting the application - you can't reopen database after exiting as a result...
6
dmjpro
by: dmjpro | last post by:
i want to know where to drop two jar fiels for JAVA MAIL....mail.jar and activation.jar????? one more thing .... is there version compatibility???? actually i downloaded JAVA MAIL 1.4 and JAF 1.1...
1
by: dhanu sahu | last post by:
Thanks I am writing Web Application and using Sqlserver inback end. User enter the data in textBox,Dropdownlist..etc When he/c click SAVE button it save on back End Database.Its Ok here... ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.