#Is there a shorter way to write this?

1 messages · Page 1 of 1 (latest)

willow peak
#

System.out.print("Enter departure time:");
int depurtureTime=keyboard.nextInt();
int BoardingTime= (depurtureTime-1);
String boardingTime=BoardingTime+":30";

pulsar valeBOT
#

<@&987246399047479336> please have a look, thanks.

pulsar valeBOT
#

While you are waiting for getting help, here are some tips to improve your experience:

Code is much easier to read if posted with syntax highlighting and proper formatting.

If nobody is calling back, that usually means that your question was not well asked and hence nobody feels confident enough answering. Try to use your time to elaborate, provide details, context, more code, examples and maybe some screenshots. With enough info, someone knows the answer for sure.

Don't forget to close your thread using the command </help-thread close:1027500463647621170> when your question has been answered, thanks.

sharp mirage
#

not really

#

you an shorten a bit of it by not having one of the variables

#
System.out.print("Enter departure time:");
int depurtureTime = keyboard.nextInt();
String boardingTime = (depurtureTime-1) +":30";
formal cipher
#

unless you remove BoardingTime variable and use that at boardingTime then there's not much you can do

sharp mirage
#

but nope

buoyant patrol
#
System.out.print("Enter departure time:");
System.out.print(keyboard.nextInt() -1 + ":30");
willow peak
formal cipher
#

if you do want to have BoardingTime variable, you can make it shorter by:

int depurtureTime = keyboard.nextInt(), BoardingTime= (depurtureTime -1 );
#

you would have to change less code that way

buoyant patrol
#

@formal cipher From a practical perspective, there is no reason to shorten this code.

formal cipher
willow peak
#

Thank you all!