Write Java-like pseudocode to specify the logic for the following program static
ID: 3583330 • Letter: W
Question
Write Java-like pseudocode to specify the logic for the following program
static double gpay(double hrs, double rate)
{
return hrs*rate;
{
static double npay(double hrs, double rate)
{
double tax = gpay(hrs,rate);
}
if (tax<300) return (tax-(tax*0.1));
return (tax-(tax*0.12));
}
}
public static void main(String args[])
{
Scanner in = new Scanner(System.in);
System.out.println(" Enter your hourly pay: ");
double rate = in.nextDouble();
System.out.println(" Enter how many hours you worked: ");
double hours = in.nextDouble();
double grosspay = gpay(rate,hours);
double netpay = npay(rate,hours);
System.out.println("Gross pay: "+grosspay+", netpay: "+netpay);
Explanation / Answer
public int diskon (int a)
{
int diskon = 15%;
return a-(a*15%);
}
diskon adalah variable local.
* Instance Variable : Variable yang didefinisikan dalam kelas, namun tidak dalam method atau object. Variable ini merujuk pada referenci suatu objek tertentu. Selalu didefinisikan dengan private access specifier.
contoh :
public class Rekening
{
private int balance;
private String name;
public void setBalance(int a)
{
balance =a;
}
public void setName(String x)
{
name =x;
}
public RekeningBank ()
{
setName(“Tidak Ada”);
setBalance (0);
}
public RekeningBank(String str, int value)
{
setNama(str);
setBalance(value);
}
public static void main (String[]args)
{
RekeningBank saya = new RekeningBank(Adrianus, 10000);
RekeningBank kamu = new RekeningBank(Juliet, 5000);
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.