0

java

Snail creeps up the vertical pole of height H feet. Each day it goes A feets up, and each night it goes B feets down. On which day will the snail reach the top of the pole?H IS GREATER THAN A>B) what is meant by error #6 in java? what is wrong in my code BELOW ?plz help; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int H = scanner.nextInt(); int A = scanner.nextInt(); int B = scanner.nextInt(); int i=0,C=0; do { C=C+A; i=i+1; if(C==H) break; else C = C-B; }while(C!=H); System.out.println(i); } }

1st Aug 2020, 3:13 AM
Priyankita Srivastava
Priyankita Srivastava - avatar
2 RĂ©ponses
+ 3
while(true) { days += 1; feetUpPole += feetPerDayUp; if(feetUpPole >= poleHeight) break; feetUpPole -= feetPerDayDownPole; }
1st Aug 2020, 3:25 AM
ChaoticDawg
ChaoticDawg - avatar
+ 1
thanks a lot for your help
1st Aug 2020, 5:05 AM
Priyankita Srivastava
Priyankita Srivastava - avatar