Jump to content

Need help with an intro level programming class

I need to create a program using five methods, and I am so close to finishing it. The program is supposed to look like this:

*******************************************************

*******************************************************

*******************************************************

Please enter the course code: CIS 120

Please enter the course name: Application Programming I

Please enter the number of students currently registered: 41

*******************************************************

*******************************************************

*******************************************************

CIS 120: Application Programming I

Total number of seats = 50

Number of students currently registered = 41

Number of seats available = 9

Everything underlined is console input. I'm making the program with Java in Jgrasp.

The code is functioning up until I attempt to print out all of the variables.

I am going to link the code that I have created.

Paluso333.java

Link to post
Share on other sites

I'm kinda out of Java Programming and mostly do JavaScript, but I feel that you should save the return values of your console1 and console2 functions somewhere. So your main method should look something like this

 

line(3);
String coursestring = console1();
int studentsreg = console2();
line(3);


int sum = calculation(seats, studentsreg);
myAwesomeFinalConsoleOutput(coursestring, sum);

If I recall correctly (man, Java 101 feels like ages ago), once executed, your main method is processed from top to bottom, halting at the user input. You currently simply ommit the values returned to your main method.

(Above code will not work out of the box for obvious reasons, regards it as some kind of pseudocode :D

 

Best,

Chris

 

edit: also, you should really reconsider the way you name your variables and methods. Its way more readable, if you'd call your stuff

public static void printEmptyLines(int count)

public static String requestCourseCodeInput()

public static String requestCourseNameInput()

public static Int requestPupilCountInput()

and so on

 

edit2: maybe it's just me, but I'm not that fond of downloading unknown executables from the internet. I saved your file as plain .txt, maybe consider uploading stuff that way or post it here dircetly using the <Code> markup

 

"We cannot change the cards we're dealt - just how we play the hand" - R. Pausch

 

CPU: Ryzen 7 3700X , Cooler: BeQuiet Dark Rock 3 Motherboard: MSI B450 Mortar Titanium RAM: 16 GB Corsair LPX 3200 GPU: EVGA RTX2070 XC Storage: Adata 120GB SSD, SanDisk 1TB SDD, 2TB WD GreenHDD Case: Fractal Design Define Mini C PSU: EVGA Supernova 650GS Peripherals: Master Keys Pro S, Logitech G402 Audio: Schiit Fulla 2 + Sennheiser HD 650. Laptop: Asus Zenbook UX 302

Link to post
Share on other sites

3 hours ago, Doomerson said:

The code is functioning up until I attempt to print out all of the variables.

I am going to link the code that I have created.

What is it doing that tells you that it's not functioning correctly?

ENCRYPTION IS NOT A CRIME

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×