Sina mashine iliibiwa.Nitakujibu nikikaa kwenye computer maana siwezi code kabisa kwa kutumia simu. Naona unatumia tablet, huna mashine mkuu?
Alafu elezea swali lako vizuri wakati huo, kwa nini mtu anaingiza hours worked? Je kuna pay per hour? Maana hapo umesema rate of pay, rate of pay per what? Rate siku zote hua ni something over something, labda 10shs/hour.
Alafu bug yako hapo tatizo ni semicolon, huoni imekuandikia kabisa?
package com.company;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
double grossSalary, payRate,extraSalary;
byte hoursWorked, serviceRecord;
Scanner userInput = new Scanner(System.in);
// prompt user to enter the payrate
System.out.println("Enter your payrate (Tsh per hour):");
payRate = userInput.nextByte();
// prompt user to enter the hours
System.out.println("Enter number of hours you worked:");
hoursWorked = userInput.nextByte();
// prompt user to enter service record
System.out.println("Enter your service record in years:");
serviceRecord = userInput.nextByte();
//check if service record is less than 10
if (serviceRecord <= 10) {
grossSalary = payRate * hoursWorked;
System.out.println("Your gross salary is:" + grossSalary);
}
//check if service record is greater than 10
else {
grossSalary = (payRate * hoursWorked);
// extraSalary is the amount of money worker receive when his service record is >10
extraSalary = grossSalary + 0.15 * grossSalary;
System.out.println("Your gross salary is:" + extraSalary);
}
}
}
Nilivyoelewa swali ni kwamba user anaweka payrate yake ambayo inakua per hour (say 2000Tsh/hour) then ataweka tena idadi ya masaa aliyofanya kazi, mpaka hapa ukizidisha payrate na idadi ya masaa, hour ina cancel unabakiwa na amount of salary in Tsh! (2000Tsh/hour*8hours)!Nitakujibu nikikaa kwenye computer maana siwezi code kabisa kwa kutumia simu. Naona unatumia tablet, huna mashine mkuu?
Alafu elezea swali lako vizuri wakati huo, kwa nini mtu anaingiza hours worked? Je kuna pay per hour? Maana hapo umesema rate of pay, rate of pay per what? Rate siku zote hua ni something over something, labda 10shs/hour.
Alafu bug yako hapo tatizo ni semicolon, huoni imekuandikia kabisa?
Write a C program which computes gross salary of an employee. Let your program input the rate of pay, hours worked, and service record in years. When the service record is greater than 10 years an allowance of 15% of gross salary is given.
Mimi nimefanya kama inavyoonekana hapa chini lakini nimekwama kidogo.
Input inakwambia iwe rate, hours na years. Hiyo basic umeitoa wapi? Haipo kwenye requirements.