Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › Application Programming › [JAVA] Multiple Scanners in Java AND Mutliple strings/Int in one println?
New Posts  All Forums:Forum Nav:

[JAVA] Multiple Scanners in Java AND Mutliple strings/Int in one println? - Page 2

post #11 of 18
Thread Starter 
Quote:
Originally Posted by FloJoe6669 View Post

you can create two different scanner objects

Scanner scan1 = new Scanner;
Scanner scan2 = new Scanner;

EDIT: ah okay glad you got it sorted thumb.gif

Cheers!
Yes I know, I just had lots of problems being a newbie at this whole Java/Coding/Programming whatever you want to call it thing!
I've almost got the much harder assignment done now, it basically asks for your name, DOB, year you were born and month you were born then figures out a score based on that.
Obviously it is useless, i'm finding it really hard redface.gif
 
Seven Seven Five
(12 items)
 
NASSY
(5 items)
 
CPUMotherboardGraphicsRAM
Convertible i5 3570k (De-Lidded) Gigabyte Z77x-D3H XFX R9 290 With Koolance Block (1179/1450) 16GB G-Skill Ares 1866 
Hard DriveHard DriveOptical DriveCooling
Samsung 840 Evo Seagate Barracuda 2TB 1x OEM DVD Drives Heatkiller Rev 3.0 
CoolingCoolingCoolingCooling
XSPC RX360 Laing D5 + XSPC Res Primochill Bloodshed Red Tubing Koolance Fullcover R9 290x Block 
CoolingOSMonitorMonitor
XSPC EX360 Windows 10 Pro x64 Asus VEH228H Asus VE228H 
MonitorKeyboardPowerCase
Aavara TS742 Dual Monitor Stand Ducky Shine II Cherry Blue RED Backlit Mechanic... Silverstone Strider 850W Thermaltake Core x71 Tempered Glass Riing Edition 
MouseMouse PadAudioOther
Zowie FK1 House of Stealth Microlab Solo6c Logitech C100 Webcam 
CPUGraphicsRAMHard Drive
Celeron N3160 HD Graphics 400 4GB DDR3 4TB WD Red 
Cooling
Some 120mm fan 
  hide details  
Reply
 
Seven Seven Five
(12 items)
 
NASSY
(5 items)
 
CPUMotherboardGraphicsRAM
Convertible i5 3570k (De-Lidded) Gigabyte Z77x-D3H XFX R9 290 With Koolance Block (1179/1450) 16GB G-Skill Ares 1866 
Hard DriveHard DriveOptical DriveCooling
Samsung 840 Evo Seagate Barracuda 2TB 1x OEM DVD Drives Heatkiller Rev 3.0 
CoolingCoolingCoolingCooling
XSPC RX360 Laing D5 + XSPC Res Primochill Bloodshed Red Tubing Koolance Fullcover R9 290x Block 
CoolingOSMonitorMonitor
XSPC EX360 Windows 10 Pro x64 Asus VEH228H Asus VE228H 
MonitorKeyboardPowerCase
Aavara TS742 Dual Monitor Stand Ducky Shine II Cherry Blue RED Backlit Mechanic... Silverstone Strider 850W Thermaltake Core x71 Tempered Glass Riing Edition 
MouseMouse PadAudioOther
Zowie FK1 House of Stealth Microlab Solo6c Logitech C100 Webcam 
CPUGraphicsRAMHard Drive
Celeron N3160 HD Graphics 400 4GB DDR3 4TB WD Red 
Cooling
Some 120mm fan 
  hide details  
Reply
post #12 of 18
Quote:
Originally Posted by FloJoe6669 View Post

you can create two different scanner objects

Scanner scan1 = new Scanner;
Scanner scan2 = new Scanner;

EDIT: ah okay glad you got it sorted thumb.gif

You can create two, but I can't see a reason why :-)

I think the OP failed to realise that you can take multiple inputs of different data types from the single scanner.

@OP - Glad it works :-)
    
CPUMotherboardGraphicsGraphics
Intel Core i7 860 Asus P7P55D-E Pro MSI GTX560 Ti TwinFrozr II MSI GTX560 Ti TwinFrozr II 
RAMHard DriveHard DriveHard Drive
Corsair 8GB DDR3 OCZ Vertex 3 Western Digital Caviar Black Western Digital Caviar Green 
Hard DriveOptical DriveCoolingOS
Samsung 840 Pro Lite-On 24x DVD-RW CoolerMaster V8 Windows 8.1 Professional 
OSMonitorMonitorMonitor
Debian 7.1 Samsung S22B350H Samsung S22B350H Samsung S22B350H 
KeyboardPowerCaseMouse
Ducky Shine II Corsair HX850 CoolerMaster Storm Enforcer Logitech M500 
Mouse PadAudio
Razer Goliathus Microsoft LifeChat LX 3000 
  hide details  
Reply
    
CPUMotherboardGraphicsGraphics
Intel Core i7 860 Asus P7P55D-E Pro MSI GTX560 Ti TwinFrozr II MSI GTX560 Ti TwinFrozr II 
RAMHard DriveHard DriveHard Drive
Corsair 8GB DDR3 OCZ Vertex 3 Western Digital Caviar Black Western Digital Caviar Green 
Hard DriveOptical DriveCoolingOS
Samsung 840 Pro Lite-On 24x DVD-RW CoolerMaster V8 Windows 8.1 Professional 
OSMonitorMonitorMonitor
Debian 7.1 Samsung S22B350H Samsung S22B350H Samsung S22B350H 
KeyboardPowerCaseMouse
Ducky Shine II Corsair HX850 CoolerMaster Storm Enforcer Logitech M500 
Mouse PadAudio
Razer Goliathus Microsoft LifeChat LX 3000 
  hide details  
Reply
post #13 of 18
Quote:
Originally Posted by dushan24 View Post

You can create two, but I can't see a reason why :-)

I think the OP failed to realise that you can take multiple inputs of different data types from the single scanner.

thats a good point actually, i kinda just skimmed over it and thought the problem was about creating multiple scanner objects. yeah creating one scanner and just using different scanner methods would definitely be more neat and tidy.
    
CPUMotherboardGraphicsRAM
Intel Core i5-2500K Gigabyte GA-Z68XP-UD4 Gigabyte GTX 970 G1 Gaming G-Skill Ripjaws 1600MHz 8gb (2x4gb)  
Hard DriveHard DriveHard DriveHard Drive
Sandisk Extreme 240GB WD Green 500GB WD Blue 500GB Seagate 500GB 
Optical DriveCoolingOSMonitor
Samsung DVD Noctua NH-D14 Windows 7 Home Premium x64 Crossover 27Q LED-P 
MonitorKeyboardPowerCase
ASUS VS248 Ducky Shine Zero D2108S (Blue-LED) (Cherry MX B... Corsair TX-750 Silverstone Raven RV01 
MouseMouse PadAudio
Logitech G9x Roccat Taito Audio Technica ATH-M50 
  hide details  
Reply
    
CPUMotherboardGraphicsRAM
Intel Core i5-2500K Gigabyte GA-Z68XP-UD4 Gigabyte GTX 970 G1 Gaming G-Skill Ripjaws 1600MHz 8gb (2x4gb)  
Hard DriveHard DriveHard DriveHard Drive
Sandisk Extreme 240GB WD Green 500GB WD Blue 500GB Seagate 500GB 
Optical DriveCoolingOSMonitor
Samsung DVD Noctua NH-D14 Windows 7 Home Premium x64 Crossover 27Q LED-P 
MonitorKeyboardPowerCase
ASUS VS248 Ducky Shine Zero D2108S (Blue-LED) (Cherry MX B... Corsair TX-750 Silverstone Raven RV01 
MouseMouse PadAudio
Logitech G9x Roccat Taito Audio Technica ATH-M50 
  hide details  
Reply
post #14 of 18
Quote:
Originally Posted by FloJoe6669 View Post

thats a good point actually, i kinda just skimmed over it and thought the problem was about creating multiple scanner objects. yeah creating one scanner and just using different scanner methods would definitely be more neat and tidy.

Glad I could help :-)
    
CPUMotherboardGraphicsGraphics
Intel Core i7 860 Asus P7P55D-E Pro MSI GTX560 Ti TwinFrozr II MSI GTX560 Ti TwinFrozr II 
RAMHard DriveHard DriveHard Drive
Corsair 8GB DDR3 OCZ Vertex 3 Western Digital Caviar Black Western Digital Caviar Green 
Hard DriveOptical DriveCoolingOS
Samsung 840 Pro Lite-On 24x DVD-RW CoolerMaster V8 Windows 8.1 Professional 
OSMonitorMonitorMonitor
Debian 7.1 Samsung S22B350H Samsung S22B350H Samsung S22B350H 
KeyboardPowerCaseMouse
Ducky Shine II Corsair HX850 CoolerMaster Storm Enforcer Logitech M500 
Mouse PadAudio
Razer Goliathus Microsoft LifeChat LX 3000 
  hide details  
Reply
    
CPUMotherboardGraphicsGraphics
Intel Core i7 860 Asus P7P55D-E Pro MSI GTX560 Ti TwinFrozr II MSI GTX560 Ti TwinFrozr II 
RAMHard DriveHard DriveHard Drive
Corsair 8GB DDR3 OCZ Vertex 3 Western Digital Caviar Black Western Digital Caviar Green 
Hard DriveOptical DriveCoolingOS
Samsung 840 Pro Lite-On 24x DVD-RW CoolerMaster V8 Windows 8.1 Professional 
OSMonitorMonitorMonitor
Debian 7.1 Samsung S22B350H Samsung S22B350H Samsung S22B350H 
KeyboardPowerCaseMouse
Ducky Shine II Corsair HX850 CoolerMaster Storm Enforcer Logitech M500 
Mouse PadAudio
Razer Goliathus Microsoft LifeChat LX 3000 
  hide details  
Reply
post #15 of 18
Thread Starter 
Quote:
Originally Posted by dushan24 View Post

You can create two, but I can't see a reason why :-)

I think the OP failed to realise that you can take multiple inputs of different data types from the single scanner.

@OP - Glad it works :-)

Quote:
Originally Posted by FloJoe6669 View Post

thats a good point actually, i kinda just skimmed over it and thought the problem was about creating multiple scanner objects. yeah creating one scanner and just using different scanner methods would definitely be more neat and tidy.

Yep, it was the first time I'd made my own java program with scanners and the first to include scanning for two different primitive types.
You could use more then one scanner but why would you? tongue.gif
The code looks neater, is smaller and runs faster with just the one. smile.gif

EDIT: Need more help rolleyes.gif
Go to OP tongue.gif
Edited by Matt-Matt - 4/7/13 at 4:21am
 
Seven Seven Five
(12 items)
 
NASSY
(5 items)
 
CPUMotherboardGraphicsRAM
Convertible i5 3570k (De-Lidded) Gigabyte Z77x-D3H XFX R9 290 With Koolance Block (1179/1450) 16GB G-Skill Ares 1866 
Hard DriveHard DriveOptical DriveCooling
Samsung 840 Evo Seagate Barracuda 2TB 1x OEM DVD Drives Heatkiller Rev 3.0 
CoolingCoolingCoolingCooling
XSPC RX360 Laing D5 + XSPC Res Primochill Bloodshed Red Tubing Koolance Fullcover R9 290x Block 
CoolingOSMonitorMonitor
XSPC EX360 Windows 10 Pro x64 Asus VEH228H Asus VE228H 
MonitorKeyboardPowerCase
Aavara TS742 Dual Monitor Stand Ducky Shine II Cherry Blue RED Backlit Mechanic... Silverstone Strider 850W Thermaltake Core x71 Tempered Glass Riing Edition 
MouseMouse PadAudioOther
Zowie FK1 House of Stealth Microlab Solo6c Logitech C100 Webcam 
CPUGraphicsRAMHard Drive
Celeron N3160 HD Graphics 400 4GB DDR3 4TB WD Red 
Cooling
Some 120mm fan 
  hide details  
Reply
 
Seven Seven Five
(12 items)
 
NASSY
(5 items)
 
CPUMotherboardGraphicsRAM
Convertible i5 3570k (De-Lidded) Gigabyte Z77x-D3H XFX R9 290 With Koolance Block (1179/1450) 16GB G-Skill Ares 1866 
Hard DriveHard DriveOptical DriveCooling
Samsung 840 Evo Seagate Barracuda 2TB 1x OEM DVD Drives Heatkiller Rev 3.0 
CoolingCoolingCoolingCooling
XSPC RX360 Laing D5 + XSPC Res Primochill Bloodshed Red Tubing Koolance Fullcover R9 290x Block 
CoolingOSMonitorMonitor
XSPC EX360 Windows 10 Pro x64 Asus VEH228H Asus VE228H 
MonitorKeyboardPowerCase
Aavara TS742 Dual Monitor Stand Ducky Shine II Cherry Blue RED Backlit Mechanic... Silverstone Strider 850W Thermaltake Core x71 Tempered Glass Riing Edition 
MouseMouse PadAudioOther
Zowie FK1 House of Stealth Microlab Solo6c Logitech C100 Webcam 
CPUGraphicsRAMHard Drive
Celeron N3160 HD Graphics 400 4GB DDR3 4TB WD Red 
Cooling
Some 120mm fan 
  hide details  
Reply
post #16 of 18
Quote:
Originally Posted by Matt-Matt View Post


Yep, it was the first time I'd made my own java program with scanners and the first to include scanning for two different primitive types.
You could use more then one scanner but why would you? tongue.gif
The code looks neater, is smaller and runs faster with just the one. smile.gif

EDIT: Need more help rolleyes.gif
Go to OP tongue.gif

There is no situation I can think of where you would need to use multiple scanners, ever.

All it will do is waste memory.

Regarding your new problem, see my code snippet below
Code:
public class test
{
        public static void main (String args[])
        {
                int a = 1;
                int b = 2;
                double c = 3.2;
                double d = 3.3;
                String e = "Hi";
                String f = "There";
                System.out.println(a + " " + b + " " + c + " " + d + " " + e + " " + f);
        }
}

Tested and working.

Your problem stems from the println(); method not knowing how to handle multiple variables under certain conditions.
Edited by dushan24 - 4/7/13 at 6:11am
    
CPUMotherboardGraphicsGraphics
Intel Core i7 860 Asus P7P55D-E Pro MSI GTX560 Ti TwinFrozr II MSI GTX560 Ti TwinFrozr II 
RAMHard DriveHard DriveHard Drive
Corsair 8GB DDR3 OCZ Vertex 3 Western Digital Caviar Black Western Digital Caviar Green 
Hard DriveOptical DriveCoolingOS
Samsung 840 Pro Lite-On 24x DVD-RW CoolerMaster V8 Windows 8.1 Professional 
OSMonitorMonitorMonitor
Debian 7.1 Samsung S22B350H Samsung S22B350H Samsung S22B350H 
KeyboardPowerCaseMouse
Ducky Shine II Corsair HX850 CoolerMaster Storm Enforcer Logitech M500 
Mouse PadAudio
Razer Goliathus Microsoft LifeChat LX 3000 
  hide details  
Reply
    
CPUMotherboardGraphicsGraphics
Intel Core i7 860 Asus P7P55D-E Pro MSI GTX560 Ti TwinFrozr II MSI GTX560 Ti TwinFrozr II 
RAMHard DriveHard DriveHard Drive
Corsair 8GB DDR3 OCZ Vertex 3 Western Digital Caviar Black Western Digital Caviar Green 
Hard DriveOptical DriveCoolingOS
Samsung 840 Pro Lite-On 24x DVD-RW CoolerMaster V8 Windows 8.1 Professional 
OSMonitorMonitorMonitor
Debian 7.1 Samsung S22B350H Samsung S22B350H Samsung S22B350H 
KeyboardPowerCaseMouse
Ducky Shine II Corsair HX850 CoolerMaster Storm Enforcer Logitech M500 
Mouse PadAudio
Razer Goliathus Microsoft LifeChat LX 3000 
  hide details  
Reply
post #17 of 18
Thread Starter 
Quote:
Originally Posted by dushan24 View Post

There is no situation I can think of where you would need to use multiple scanners, ever.

All it will do is waste memory.

Regarding your new problem, see my code snippet below
Code:
public class test
{
        public static void main (String args[])
        {
                int a = 1;
                int b = 2;
                double c = 3.2;
                double d = 3.3;
                String e = "Hi";
                String f = "There";
                System.out.println(a + " " + b + " " + c + " " + d + " " + e + " " + f);
        }
}

Tested and working.

Your problem stems from the println(); method not knowing how to handle multiple variables under certain conditions.

Ah yep! I never thought of doing that one! Just making the words/strings of text I need as variables! Very smart cookie! thumb.gif
 
Seven Seven Five
(12 items)
 
NASSY
(5 items)
 
CPUMotherboardGraphicsRAM
Convertible i5 3570k (De-Lidded) Gigabyte Z77x-D3H XFX R9 290 With Koolance Block (1179/1450) 16GB G-Skill Ares 1866 
Hard DriveHard DriveOptical DriveCooling
Samsung 840 Evo Seagate Barracuda 2TB 1x OEM DVD Drives Heatkiller Rev 3.0 
CoolingCoolingCoolingCooling
XSPC RX360 Laing D5 + XSPC Res Primochill Bloodshed Red Tubing Koolance Fullcover R9 290x Block 
CoolingOSMonitorMonitor
XSPC EX360 Windows 10 Pro x64 Asus VEH228H Asus VE228H 
MonitorKeyboardPowerCase
Aavara TS742 Dual Monitor Stand Ducky Shine II Cherry Blue RED Backlit Mechanic... Silverstone Strider 850W Thermaltake Core x71 Tempered Glass Riing Edition 
MouseMouse PadAudioOther
Zowie FK1 House of Stealth Microlab Solo6c Logitech C100 Webcam 
CPUGraphicsRAMHard Drive
Celeron N3160 HD Graphics 400 4GB DDR3 4TB WD Red 
Cooling
Some 120mm fan 
  hide details  
Reply
 
Seven Seven Five
(12 items)
 
NASSY
(5 items)
 
CPUMotherboardGraphicsRAM
Convertible i5 3570k (De-Lidded) Gigabyte Z77x-D3H XFX R9 290 With Koolance Block (1179/1450) 16GB G-Skill Ares 1866 
Hard DriveHard DriveOptical DriveCooling
Samsung 840 Evo Seagate Barracuda 2TB 1x OEM DVD Drives Heatkiller Rev 3.0 
CoolingCoolingCoolingCooling
XSPC RX360 Laing D5 + XSPC Res Primochill Bloodshed Red Tubing Koolance Fullcover R9 290x Block 
CoolingOSMonitorMonitor
XSPC EX360 Windows 10 Pro x64 Asus VEH228H Asus VE228H 
MonitorKeyboardPowerCase
Aavara TS742 Dual Monitor Stand Ducky Shine II Cherry Blue RED Backlit Mechanic... Silverstone Strider 850W Thermaltake Core x71 Tempered Glass Riing Edition 
MouseMouse PadAudioOther
Zowie FK1 House of Stealth Microlab Solo6c Logitech C100 Webcam 
CPUGraphicsRAMHard Drive
Celeron N3160 HD Graphics 400 4GB DDR3 4TB WD Red 
Cooling
Some 120mm fan 
  hide details  
Reply
post #18 of 18
Quote:
Originally Posted by Matt-Matt View Post

Ah yep! I never thought of doing that one! Just making the words/strings of text I need as variables! Very smart cookie! thumb.gif

You're welcome.
    
CPUMotherboardGraphicsGraphics
Intel Core i7 860 Asus P7P55D-E Pro MSI GTX560 Ti TwinFrozr II MSI GTX560 Ti TwinFrozr II 
RAMHard DriveHard DriveHard Drive
Corsair 8GB DDR3 OCZ Vertex 3 Western Digital Caviar Black Western Digital Caviar Green 
Hard DriveOptical DriveCoolingOS
Samsung 840 Pro Lite-On 24x DVD-RW CoolerMaster V8 Windows 8.1 Professional 
OSMonitorMonitorMonitor
Debian 7.1 Samsung S22B350H Samsung S22B350H Samsung S22B350H 
KeyboardPowerCaseMouse
Ducky Shine II Corsair HX850 CoolerMaster Storm Enforcer Logitech M500 
Mouse PadAudio
Razer Goliathus Microsoft LifeChat LX 3000 
  hide details  
Reply
    
CPUMotherboardGraphicsGraphics
Intel Core i7 860 Asus P7P55D-E Pro MSI GTX560 Ti TwinFrozr II MSI GTX560 Ti TwinFrozr II 
RAMHard DriveHard DriveHard Drive
Corsair 8GB DDR3 OCZ Vertex 3 Western Digital Caviar Black Western Digital Caviar Green 
Hard DriveOptical DriveCoolingOS
Samsung 840 Pro Lite-On 24x DVD-RW CoolerMaster V8 Windows 8.1 Professional 
OSMonitorMonitorMonitor
Debian 7.1 Samsung S22B350H Samsung S22B350H Samsung S22B350H 
KeyboardPowerCaseMouse
Ducky Shine II Corsair HX850 CoolerMaster Storm Enforcer Logitech M500 
Mouse PadAudio
Razer Goliathus Microsoft LifeChat LX 3000 
  hide details  
Reply
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Application Programming
Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › Application Programming › [JAVA] Multiple Scanners in Java AND Mutliple strings/Int in one println?