I need help getting started. I do fine reading and understanding code but for so
ID: 3883694 • Letter: I
Question
I need help getting started. I do fine reading and understanding code but for some reason I go blank at a white screen! help please!!
Explanation / Answer
/*
Sample Output
*/
import java.util.Scanner;class Main
{
public static void main(String[] args)
{
// declaring variables
Scanner sc = new Scanner(System.in);
int min,mps, totalmps = 0, count=0;
//taking user input of min value
System.out.print("Input min MPH value:");
min = sc.nextInt();
System.out.println("--------------- MPH MPS");
// checking for the condition and looping
while(min<=140)
{
// to pring line
if(count%5 == 0)
{
System.out.println("---------------");
}
// converting to mps, math for average and incrementing count
mps = (min*60*60);
totalmps += mps;
count++;
// printing output of conversion
System.out.printf("%d %d ",min,mps);
min +=1;
}
// printing average and count
System.out.printf("--------------- Average m/s is %f ", totalmps/(count*1.0));
System.out.printf("Total number of entries are %d",count);
}
}
/*
Sample Output
Input min MPH value: 10 --------------- MPH MPS --------------- 10 36000 11 39600 12 43200 13 46800 14 50400 --------------- 15 54000 16 57600 17 61200 18 64800 19 68400 --------------- 20 72000 21 75600 22 79200 23 82800 24 86400 --------------- 25 90000 26 93600 27 97200 28 100800 29 104400 --------------- 30 108000 31 111600 32 115200 33 118800 34 122400 --------------- 35 126000 36 129600 37 133200 38 136800 39 140400 --------------- 40 144000 41 147600 42 151200 43 154800 44 158400 --------------- 45 162000 46 165600 47 169200 48 172800 49 176400 --------------- 50 180000 51 183600 52 187200 53 190800 54 194400 --------------- 55 198000 56 201600 57 205200 58 208800 59 212400 --------------- 60 216000 61 219600 62 223200 63 226800 64 230400 --------------- 65 234000 66 237600 67 241200 68 244800 69 248400 --------------- 70 252000 71 255600 72 259200 73 262800 74 266400 --------------- 75 270000 76 273600 77 277200 78 280800 79 284400 --------------- 80 288000 81 291600 82 295200 83 298800 84 302400 --------------- 85 306000 86 309600 87 313200 88 316800 89 320400 --------------- 90 324000 91 327600 92 331200 93 334800 94 338400 --------------- 95 342000 96 345600 97 349200 98 352800 99 356400 --------------- 100 360000 101 363600 102 367200 103 370800 104 374400 --------------- 105 378000 106 381600 107 385200 108 388800 109 392400 --------------- 110 396000 111 399600 112 403200 113 406800 114 410400 --------------- 115 414000 116 417600 117 421200 118 424800 119 428400 --------------- 120 432000 121 435600 122 439200 123 442800 124 446400 --------------- 125 450000 126 453600 127 457200 128 460800 129 464400 --------------- 130 468000 131 471600 132 475200 133 478800 134 482400 --------------- 135 486000 136 489600 137 493200 138 496800 139 500400 --------------- 140 504000 --------------- Average m/s is 270000.000000 Total number of entries are 131
*/
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.