#include <stdio.h>
#include <math.h>
int main( ) {
int pilihan;
double v0, v, a, t, s;
printf ( "Program Menghitung Gerak Lurus Berubah Beraturan (GLBB)\n " ) ;
printf ( "Pilih rumus yang ingin digunakan:\n " ) ;
printf ( "1. Menghitung Kecepatan Akhir (v)\n " ) ;
printf ( "2. Menghitung Jarak (s)\n " ) ;
printf ( "3. Menghitung Kecepatan Akhir dengan persamaan v^2 = v0^2 + 2as\n " ) ;
printf ( "Masukkan pilihan (1/2/3): " ) ;
scanf ( "%d" , & pilihan) ;
switch ( pilihan) {
case 1 : // Menghitung Kecepatan Akhir
printf ( "Masukkan kecepatan awal (v0) dalam m/s: " ) ;
scanf ( "%lf" , & v0) ;
printf ( "Masukkan percepatan (a) dalam m/s^2: " ) ;
scanf ( "%lf" , & a) ;
printf ( "Masukkan waktu (t) dalam detik: " ) ;
scanf ( "%lf" , & t) ;
v = v0 + a * t;
printf ( "Kecepatan akhir (v) = %.2lf m/s\n " , v) ;
break ;
case 2 : // Menghitung Jarak
printf ( "Masukkan kecepatan awal (v0) dalam m/s: " ) ;
scanf ( "%lf" , & v0) ;
printf ( "Masukkan percepatan (a) dalam m/s^2: " ) ;
scanf ( "%lf" , & a) ;
printf ( "Masukkan waktu (t) dalam detik: " ) ;
scanf ( "%lf" , & t) ;
s = v0 * t + 0.5 * a * t * t;
printf ( "Jarak yang ditempuh (s) = %.2lf meter\n " , s) ;
break ;
case 3 : // Menghitung Kecepatan Akhir dengan persamaan v^2 = v0^2 + 2as
printf ( "Masukkan kecepatan awal (v0) dalam m/s: " ) ;
scanf ( "%lf" , & v0) ;
printf ( "Masukkan percepatan (a) dalam m/s^2: " ) ;
scanf ( "%lf" , & a) ;
printf ( "Masukkan jarak (s) dalam meter: " ) ;
scanf ( "%lf" , & s) ;
v = sqrt ( v0 * v0 + 2 * a * s) ;
printf ( "Kecepatan akhir (v) = %.2lf m/s\n " , v) ;
break ;
default :
printf ( "Pilihan tidak valid.\n " ) ;
break ;
}
return 0 ;
}
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GEgKiB0OwogICAgICAgICAgICBwcmludGYoIktlY2VwYXRhbiBha2hpciAodikgPSAlLjJsZiBtL3NcbiIsIHYpOwogICAgICAgICAgICBicmVhazsKCiAgICAgICAgY2FzZSAyOiAvLyBNZW5naGl0dW5nIEphcmFrCiAgICAgICAgICAgIHByaW50ZigiTWFzdWtrYW4ga2VjZXBhdGFuIGF3YWwgKHYwKSBkYWxhbSBtL3M6ICIpOwogICAgICAgICAgICBzY2FuZigiJWxmIiwgJnYwKTsKICAgICAgICAgICAgcHJpbnRmKCJNYXN1a2thbiBwZXJjZXBhdGFuIChhKSBkYWxhbSBtL3NeMjogIik7CiAgICAgICAgICAgIHNjYW5mKCIlbGYiLCAmYSk7CiAgICAgICAgICAgIHByaW50ZigiTWFzdWtrYW4gd2FrdHUgKHQpIGRhbGFtIGRldGlrOiAiKTsKICAgICAgICAgICAgc2NhbmYoIiVsZiIsICZ0KTsKCiAgICAgICAgICAgIHMgPSB2MCAqIHQgKyAwLjUgKiBhICogdCAqIHQ7CiAgICAgICAgICAgIHByaW50ZigiSmFyYWsgeWFuZyBkaXRlbXB1aCAocykgPSAlLjJsZiBtZXRlclxuIiwgcyk7CiAgICAgICAgICAgIGJyZWFrOwoKICAgICAgICBjYXNlIDM6IC8vIE1lbmdoaXR1bmcgS2VjZXBhdGFuIEFraGlyIGRlbmdhbiBwZXJzYW1hYW4gdl4yID0gdjBeMiArIDJhcwogICAgICAgICAgICBwcmludGYoIk1hc3Vra2FuIGtlY2VwYXRhbiBhd2FsICh2MCkgZGFsYW0gbS9zOiAiKTsKICAgICAgICAgICAgc2NhbmYoIiVsZiIsICZ2MCk7CiAgICAgICAgICAgIHByaW50ZigiTWFzdWtrYW4gcGVyY2VwYXRhbiAoYSkgZGFsYW0gbS9zXjI6ICIpOwogICAgICAgICAgICBzY2FuZigiJWxmIiwgJmEpOwogICAgICAgICAgICBwcmludGYoIk1hc3Vra2FuIGphcmFrIChzKSBkYWxhbSBtZXRlcjogIik7CiAgICAgICAgICAgIHNjYW5mKCIlbGYiLCAmcyk7CgogICAgICAgICAgICB2ID0gc3FydCh2MCAqIHYwICsgMiAqIGEgKiBzKTsKICAgICAgICAgICAgcHJpbnRmKCJLZWNlcGF0YW4gYWtoaXIgKHYpID0gJS4ybGYgbS9zXG4iLCB2KTsKICAgICAgICAgICAgYnJlYWs7CgogICAgICAgIGRlZmF1bHQ6CiAgICAgICAgICAgIHByaW50ZigiUGlsaWhhbiB0aWRhayB2YWxpZC5cbiIpOwogICAgICAgICAgICBicmVhazsKICAgIH0KCiAgICByZXR1cm4gMDsKfQo=