Thread:SamwiseFilmore/@comment-30645975-20170115043219/@comment-30645975-20170115194832

annotated code: import std.stdio;

void main { bool done = false; while (done == false) { //keeps program open real itemPrice; writeln(" "); writeln("Price of item?"); readf(" %s", &itemPrice); if (itemPrice % 2 == 0) { //even or odd real evenAverage = (itemPrice / 2); if ((evenAverage % 2 == 0)){ //divisible by 4-for finding range real EvenDiff = (evenAverage / 2); real EvenLarge = (itemPrice + EvenDiff); real EvenSmall = (itemPrice - EvenDiff); writeln("Low Number: ", EvenSmall, " High Number: ", EvenLarge); }		else if (itemPrice == 2){ //special case - 2 is even but not by 4 writeln("Low Number: 1 ", " High Number: 3"); }		else { //making a range for even numbers real evenDiff = ((evenAverage / 2) + 0.5); real evenLarge = (itemPrice + evenDiff); real evenSmall = ((itemPrice - evenDiff) +1 ); writeln("Low Number: ", evenSmall, " High Number: ", evenLarge); }	}		else{ //for odd numbers real oddAverage = ((itemPrice) / 2 + 0.5); if ((oddAverage % 2) != 0){ real oddDiffA = ((oddAverage / 2) + 0.5); real oddDiffB = ((oddAverage / 2) - 0.5); real oddLarge = (itemPrice + oddDiffA); real oddSmall = (itemPrice - oddDiffB); writeln("Low Number: ", oddSmall, " High Number: ", oddLarge); }		else { //for odd numbers with even halfs real OddDiff = (oddAverage / 2); real OddLarge = (itemPrice + OddDiff); real OddSmall = (itemPrice - OddDiff); writeln("Low Number: ", OddSmall, " High Number: ", OddLarge); }	}	} }