Temperature and Salary Conversion Algorithms
Temperature and Salary Conversion Algorithms
R = 3.1416 x S / 180
EXERCISE II:
Write an algorithm that reads a temperature in degrees Celsius (C) and the
convert it to its equivalents in degrees Fahrenheit (F), degrees Kelvin (K) and
Rankine degrees (R). Use the following formulas:
(9*centigrados/5)+32
translatedText
[Link]();
}
}
EXERCISE III
To estimate a child's weight in pediatric emergency situations, one should
use the following formula:
EXERCISE IV:
A hospital has received a special donation that will be distributed among the
áreas de Pediatría, Medicina General, Ginecología y Traumatología. Cada área
will receive a part of the donation equivalent to:
EXERCISE V:
A company manufactures standard size polo shirts applying a discount.
11.5% of the purchase amount.
The amount of the purchase is calculated by multiplying the price of the polo by the
number of polos acquired.
The amount to be paid is calculated by subtracting the purchase amount from the amount of
discount.
Additionally, the company offers two pens for each polo purchased.
Given the price of the polo and the quantity of polos purchased, design an algorithm.
that determines the purchase amount, the discount amount, the amount to
pay and the number of gift pens that correspond to a customer.
EXERCISE VI:
A company has decided to grant a bonus to its employees for the only time.
The bonus will consist of the sum of a bonus for children
plus a bonus for length of service. The bonus for children will be equal
S/. 25 for each child. The service time bonus will be equal to S/. 50
for each year of service. Given the number of children and the number of
years of service, design an algorithm that determines the amount of the
bonus for children, the amount of the service time bonus and the
total bonus amount due to an employee.
EXERCISE VII:
A company pays its employees a gross salary that is equal to the sum of
a basic salary plus a commission. The basic salary is equal to S/. 350. The
commission is equal to 8% of the amount sold in the month. The legal discount is
equal to 15% of the gross salary. The net salary is equal to the gross salary minus
minus the discount. Given the amount sold for the month, design an algorithm that
determine the basic salary, the commission, the gross salary, the deduction and the
net salary of an employee of the company.
Gross salary:
Commission:
Discount:
Net salary:
}
protected void actionPerformedBtnDelete(ActionEvent arg0) {
//DELETE
[Link]("");
[Link]();
}
}
EXERCISE VIII:
A store has put shirts on sale offering a double
12% discount. The purchase amount is equal to the product of the price of the
shirt for the number of shirts purchased. The first discount is equal to the
12% of the purchase amount. The second discount is equal to 12% of the
subtract the amount of the purchase minus the first discount. The amount of
The total discount is equal to the sum of the first and second discount. The amount
the amount to be paid is equal to the purchase amount minus the discount amount
total. Given the price of the shirt and the quantity of shirts purchased, design
an algorithm that determines the purchase amount, the total discount amount and
the amount to be paid corresponding to a client.
[Link]("");
[Link]("");
[Link]();
}
protected void actionPerformedBtnClose(ActionEvent e) {
dispose();
}
}
Java Basic Exercises Sequential Structure
Relationship No. 2: Exercises 4, 5, 6, and 7
Exercise 4:
Program that reads a number of degrees Celsius and converts it to degrees.
Fahrenheit.
The corresponding formula to convert from Celsius to Fahrenheit is:
F = 32 + (9 * C / 5)
import [Link].*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner([Link]);
double gradosC, gradosF;
[Link]("Introduce degrees Celsius:");
degreesC = [Link]();
degreesF = 32 + (9 * degreesC / 5);
[Link](gradosC + " ºC = " + gradosF + " ºF");
}
}
Exercise 5. Program that reads the value of the radius of a circle from the keyboard and
calculate and display on screen the length and area of the circumference.
import [Link].*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner([Link]);
double radius, longitude, area;
[Link]("Enter the radius of the circumference:");
[Link]();
length = 2 * [Link] * radius;
area = [Link] * [Link](radius, 2);
[Link]("Length of the circumference -> " + length);
[Link]("Area of the circle -> " + area);
}
}
Program that allows entering 12 values and shows how many are positive and how many are negative.
negatives and how many null
import [Link];
int []x;
x = new int[12];
int positivos=0,negativos=0,nulos=0;
for(int i=0; i > 0)
positives++;
}
for(int i=0; i<[Link]; i++)
{
if(x[i]<0)
{
negatives++;
}
}
for(int i=0; i<[Link];i++){
if(x[i]==0){
null++;
}
}
The number of positive numbers is
The number of negative numbers is
negatives)
The number of null values is
}
}