Algorithm
Salary
Adapted by Neilor Tonin, URI Brazil
Write a program that reads an employee's number, his/her worked hours number in a month and the amount he received per hour. Print the employee's number and salary that he/she will receive at end of the month, with two decimal places.
- Don’t forget to print the line's end after the result, otherwise you will receive “Presentation Error”.
- Don’t forget the space before and after the equal signal and after the U$.
Input
The input file contains 2 integer numbers and 1 value of floating point, representing the number, worked hours amount and the amount the employee receives per worked hour.
Output
Print the number and the employee's salary, according to the given example, with a blank space before and after the equal signal.
Input Samples | Output Samples |
25 |
NUMBER = 25 |
1 |
NUMBER = 1 |
6 |
NUMBER = 6 |
Code Examples
#1 Code Example with C Programming
Code -
C Programming
#include <stdio.h>
int main(){
int NUMBER,hours;
float amount,SALARY;
scanf("%d %d %f", &NUMBER, &hours, &amount);
SALARY = hours * amount;
printf("NUMBER = %d\n",NUMBER);
printf("SALARY = U$ %0.2f\n", SALARY);//SALARY = U$ 4100.00
return 0;
}
Copy The Code &
Try With Live Editor
Input
100
5.50
Output
#2 Code Example with C++ Programming
Code -
C++ Programming
#include <cstdio>
int main()
{
int a;
int b;
float c;
scanf("%d", &a);
scanf("%d", &b);
scanf("%f", &c);
printf("NUMBER = %d\n", a);
printf("SALARY = U$ %.2f\n", b * c);
return 0;
}
Copy The Code &
Try With Live Editor
Input
200
20.50
Output
#3 Code Example with Java Programming
Code -
Java Programming
import java.util.Scanner;
public class Main {
public static void main(String[] args){
int NUMBER,hours;
float amount,SALARY;
Scanner sc = new Scanner(System.in);
NUMBER = sc.nextInt();
hours = sc.nextInt();
amount = sc.nextFloat();
SALARY = hours * amount;
System.out.printf("NUMBER = %d\n",NUMBER);
System.out.printf("SALARY = U$ %0.2f\n", SALARY);//SALARY = U$ 4100.00
}
}
Copy The Code &
Try With Live Editor
Input
145
15.55
Output
#4 Code Example with Python Programming
Code -
Python Programming
numfunc = int(input())
hrtrab = int(input())
valorhr = float(input())
salario = float(hrtrab * valorhr)
print("NUMBER = %d" %numfunc)
print("SALARY = U$ %0.2f" %salario)
Copy The Code &
Try With Live Editor
Input
200
20.50
Output