User Profile
Collapse
-
using package in main() method
I am trying to format numbers in an output using 3 sub classes and methods. Having trouble. I am using a package to do this I have imported the package. Any thoughts would help. -
thanks for the interpetation I have used C in past makes sense. thanks, for helping me out -
Not quite sure what I should tag as [CODE]
Error reads as follows: variable numHammers might not have been initialized
totalCost = (numHackSaws*HA CKSAW_COST) + (numHammers*HAM MER_COST) +
I am only trying to determine if user put an int when asked for number of 2nd item.
I have never used any of the scanner methods to check validation of inputLeave a comment:
-
import java.util.Date;
import java.util.Scann er;
class JohnVanHoutanP2
{
Code:private static final double HACKSAW_COST = 15.99; //class constants private static final double HAMMER_COST = 12.18; private static final double HARDHAT_COST = 18.75; private static final double DRILL_COST = 19.99; private static final double SAFETYGOGGLES_COST = 16.47; private static final
Leave a comment:
-
To use hasNextInt() in scanner class to validate input do I have to add in a range check for this to work.Leave a comment:
-
I got 5 Items that user inputs amount of product he or she wants, only trying to determine if user enters an int when entering number for second product. I have been searching all over net for examples. I am sure I am missing something simple. I get an error saying numHammers not intailized. Puzzeled. Here is my input of code.
System.out.prin t("How many Hacksaws? ");
numHackSaws = input.nextInt() ;...Leave a comment:
-
-
Thanks have fixed problem, but now I have error that my varaible might not have been intialized looking for numHammers which is my int. I new to java and trying to learn this.Leave a comment:
-
Using hasNextInt()
Trying to code in hasNextInt() for data type checking. Basicall my code ask user for input and if user doesn't use an int they get an error. I know i should have a if and else statement with this.
I am trying this data type checking in this block of code and I get tons of errors
while (isValid==false )
}
System.out.prin t("How many Hammers? ");
if(input.hasNex tInt())... -
New to Java, my teacher has confused me with detail line
In a program with parent and child classes she has asked me to print a detail line with 3 objects. Line should print name, type of object "which is a toString()", total of tuition and books. Is this the the same as I have been doing like:
ScholarshipStud ent student 1 = new ScholarshipStud ent ( "", "Joe", etc, etc.)
then later I will create this to print in output.
No activity results to display
Show More
Leave a comment: