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 · ·