473,785 Members | 2,137 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

22 New Member
What is wrong with this?? Here are the two classes...SandB ox 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.prin tln("The answer is=" + ghi);
}// End if
System.out.prin tln("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.prin tln ("total == MAX and is < sum.");
else
System.out.prin tln ("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.prin tln ("The length is minimal.");
Oct 15 '06 #1
4 1982
foleyflint
9 New Member
Let me give you an example of a Scanner Object below:

System.out.prin t("Type input: ");
Scanner reader=new Scanner(System. in);
String myText=reader.n extLine();
System.out.prin tln("Your text is: "+myText);

This way you are I think able to adjust your code and make it work.
Oct 15 '06 #2
foleyflint
9 New Member
_______________ _______________ _______________ _______________ ______

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

if (total == MAX)
if (total < sum)
System.out.prin tln ("total == MAX and is < sum.");
else
System.out.prin tln ("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.prin tln ("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 New Member
_______________ _______________ _______________ _______________ ______

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

if (total == MAX)
if (total < sum)
System.out.prin tln ("total == MAX and is < sum.");
else
System.out.prin tln ("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.prin tln ("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
foleyflint
9 New Member
=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
3176
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 frame sorting technique used in buffer. 3.C program to implement MLMA Collision free protocol.
1
1363
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 by email , by using ASP This notificatin is to notify that person before one week for an application expiration.. i appreciate u'r help plz send me email.....
4
1911
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 100 shares of stock in company X , in each of january , april , and september and sell 100 shares in each of june and november the price per share in these months were jan apr jun sep nov
9
2395
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 that creates non-JavaScript problems that can be fixed using JavaScript. With the Microsoft update installed, Java applets (as well as other content such as Flash videos) are unable to receive user input until an activating click or key press....
5
1340
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 problem how to apply the constraint that only 1 user should have same name..should i use the constarint in database or should is there anyway of checking this in aplication code. also help me out of hw to use ILDASM as it gives error P.E cannot be...
0
1162
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 errors i am getting : error C2440: 'initializing' : cannot convert from 'Transaction_structure ' to 'Transaction_structure *' error C2664: 'transact' : cannot convert parameter 1 from 'Transaction_structure ' to 'Transaction_structure &' ...
9
3946
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 - I have read every post out there and spent hours trying to figure out the problem with no success whatsoever - I have constrained the problem to one form however, and I think it's hiding somewhere in my code associated with this form, which is...
6
1431
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 and i have JDK 1.3. so is there any chance of incompatibility???? plz help. kind regards. dmjpro.
1
734
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... But I need after SAVE click the page's data or Controls are Inactive means not editable.Even you post back /use BACK Button in IE .
0
9647
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9489
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10356
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9959
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8988
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7509
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6744
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5396
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
2893
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.