Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › [Java] Write an application program that prints AAA BBB CCC in three different ways.
New Posts  All Forums:Forum Nav:

[Java] Write an application program that prints AAA BBB CCC in three different ways.

post #1 of 6
Thread Starter 
I'm taking a Java course and it's quite fun but I don't quite understand what the question wants me to do here. Anybody care to explain?
Quote:
Problem 2. Write an application program that prints AAAAAAA BBBBBBB
CCCCCCC in three different ways:

a) on one line
b) on three lines
c) inside a box made up of the characters * and =


This is what I have but I know that it's wrong.
Quote:
class Homework1b {

public static void main (String[] args) {

System.out.println ("AAAAAAA");
System.out.println ("BBBBBBB");
System.out.println ("CCCCCCC");

}
}
post #2 of 6
class Homework1b {

public static void main (String[] args) {

//one line
System.out.println ("AAAAAAA BBBBBBB CCCCCCC");

//separate lines
System.out.println ("AAAAAAA");
System.out.println ("BBBBBBB");
System.out.println ("CCCCCCC");

//as for the * = box, I can't be completely sure this is the format they want, but
System.out.println ("=========");
System.out.println ("*AAAAAAA*");
System.out.println ("*BBBBBBB*");
System.out.println ("*CCCCCCC*");
System.out.println ("=========");

}
}

Hoping this helps. I'm good with java, but the third queestion, as you know, is real vague.
post #3 of 6
Quote:
Originally Posted by TwentySpades View Post

class Homework1b {

public static void main (String[] args) {

//one line
System.out.println ("AAAAAAA BBBBBBB CCCCCCC");

//separate lines
System.out.println ("AAAAAAA");
System.out.println ("BBBBBBB");
System.out.println ("CCCCCCC");

//as for the * = box, I can't be completely sure this is the format they want, but
System.out.println ("=========");
System.out.println ("*AAAAAAA*");
System.out.println ("*BBBBBBB*");
System.out.println ("*CCCCCCC*");
System.out.println ("=========");

}
}

Hoping this helps. I'm good with java, but the third queestion, as you know, is real vague.
I dont know about the third question either but personally for the first one id do basically what you did. For the third one id do this though:
System.out.println("AAAAAAA \n BBBBBBB \n CCCCCCC");
Could do a regular print rather than println too if wanted. Seems cleaner on one line of code, less inefficient.
Wrecking Ball.
(18 items)
 
   
CPUMotherboardGraphicsRAM
Intel Core i5 2500K Asus p8z68-v/gen 3 Asus 670 top 16 GB (total) G.skill ripjaws 1333mhz 
Hard DriveHard DriveOptical DriveCooling
Seagate 1TB 7200rpm HDD Crucial M4 256GB ASUS 24x CD/DVD drive Corsair H80i 
OSMonitorPowerCase
Windows 7 home viewsonic 27 inch 1ms response Corsair AX750 NZXT Switch 810 
MouseAudioAudio
razer deathadder turtle beach x12 Sennheiser HD280 
CPUMotherboardGraphicsGraphics
Intel i7 3770k ASUS p8z68-vpro/gen3 Gigabyte 7950 3gb Gigabyte 7950 3gb 
RAMRAMHard DriveCooling
GSkill Ripjaws X 8gb 2133mhz G skill Ripjaws X 8gb 2133mhz Crucial M4 512gb ssd Corsair H100i 
MonitorKeyboardPowerCase
Auria 1440P 27" IPS Ducky OCN Cherry MX blue Silverstone 1000w NZXT switch 810 
Audio
ASUS xonar DG 
  hide details  
Reply
Wrecking Ball.
(18 items)
 
   
CPUMotherboardGraphicsRAM
Intel Core i5 2500K Asus p8z68-v/gen 3 Asus 670 top 16 GB (total) G.skill ripjaws 1333mhz 
Hard DriveHard DriveOptical DriveCooling
Seagate 1TB 7200rpm HDD Crucial M4 256GB ASUS 24x CD/DVD drive Corsair H80i 
OSMonitorPowerCase
Windows 7 home viewsonic 27 inch 1ms response Corsair AX750 NZXT Switch 810 
MouseAudioAudio
razer deathadder turtle beach x12 Sennheiser HD280 
CPUMotherboardGraphicsGraphics
Intel i7 3770k ASUS p8z68-vpro/gen3 Gigabyte 7950 3gb Gigabyte 7950 3gb 
RAMRAMHard DriveCooling
GSkill Ripjaws X 8gb 2133mhz G skill Ripjaws X 8gb 2133mhz Crucial M4 512gb ssd Corsair H100i 
MonitorKeyboardPowerCase
Auria 1440P 27" IPS Ducky OCN Cherry MX blue Silverstone 1000w NZXT switch 810 
Audio
ASUS xonar DG 
  hide details  
Reply
post #4 of 6
Thread Starter 
Cool, thanks a lot guys. biggrin.gif
post #5 of 6
Quote:
Originally Posted by General121 View Post

I dont know about the third question either but personally for the first one id do basically what you did. For the third one id do this though:
System.out.println("AAAAAAA \n BBBBBBB \n CCCCCCC");
Could do a regular print rather than println too if wanted. Seems cleaner on one line of code, less inefficient.

agreed here, for the 2nd option. I was taught to keep things simple, so if you can do it in one line of code you should. you could essentially do the same for the 3rd option too, though it owuld be a bit longer: System.out.println(""========= \n *AAAAAAA* \n *BBBBBBB* \n *CCCCCCC* \n =========");
post #6 of 6
you should put a look statement with a if condition on the counter biggrin.gif
Mini Dragon
(19 items)
 
  
CPUMotherboardGraphicsRAM
Intel Xeon E3-1230 V2 ASRock H77M-ITX LGA 1155 Intel H77 GIGABYTE 680  CORSAIR Vengeance LP 16GB 
Hard DriveOptical DriveCoolingOS
MZ-7TD500BW Samsung 840  white laser ... corsair H90 Windows 7 Pro 
MonitorMonitorMonitorMonitor
Qnix QX2700 Asus VS247H-P Asus VS247H-P Asus VS247H-P 
KeyboardPowerCaseMouse
Ducky MK Green LED Full Board Silverstone Tek Strider Series ATX12V/EPS12V 55... Fractal Node 304 Logitech G9 
Mouse PadAudioAudio
X Trak M-AUDIO BX5 G930 
  hide details  
Reply
Mini Dragon
(19 items)
 
  
CPUMotherboardGraphicsRAM
Intel Xeon E3-1230 V2 ASRock H77M-ITX LGA 1155 Intel H77 GIGABYTE 680  CORSAIR Vengeance LP 16GB 
Hard DriveOptical DriveCoolingOS
MZ-7TD500BW Samsung 840  white laser ... corsair H90 Windows 7 Pro 
MonitorMonitorMonitorMonitor
Qnix QX2700 Asus VS247H-P Asus VS247H-P Asus VS247H-P 
KeyboardPowerCaseMouse
Ducky MK Green LED Full Board Silverstone Tek Strider Series ATX12V/EPS12V 55... Fractal Node 304 Logitech G9 
Mouse PadAudioAudio
X Trak M-AUDIO BX5 G930 
  hide details  
Reply
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Coding and Programming
Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › [Java] Write an application program that prints AAA BBB CCC in three different ways.