Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.
i am trying to display some inputted data with grammatical correctness, but am having trouble programming this without an enormous amount of code. I want to tell it to print an 'and' before the last value in a sequence. But in a series of 8 values that are only printed if it doesn't equal 0 i can't figure out how to tell it this. whether in a single command or a clever series. please give suggestions. here's my code in case that helps...
if (twenty != 0) // the number of twenties given in change
if (twenty == 1)
System.out.print(twenty + " twenty dollar bill");
System.out.print(twenty + " twenty dollar bills");
if (ten != 0 || five != 0 || one != 0 || quarter != 0 || dime != 0 || nickel != 0 || penny != 0)// if these aren't zero then it's a sequence that requires a comma
System.out.print(", "); // what if only one variable follows? i do i tell it to instead print an 'and'? [/code]
0 · ·