Answer:
// program in C++.
// headers
#include <bits/stdc++.h>
using namespace std;
// main function
int main()
{
// Variable
int num;
cout << "Enter a number between 1 and 10: ";
// read input
cin >> num;
// validate input number
while(num<1||num>10)
{
// if input is wrong then print error message
cout<<"Wrong input!!Enter again:";
// read again
cin>>num;
}
// print output
cout << "The Roman numeral for "<<num<<" is:";
// switch
switch (num)
{
case 1:
// if input is 1
cout<<"I"<<endl;
// exit the switch
break;
case 2:
// if input is 2
cout<<"II"<<endl;
// exit the switch
break;
case 3:
// if input is 3
cout<<"III"<<endl;
// exit the switch
break;
case 4:
// if input is 4
cout<<"IV"<<endl;
// exit the switch
break;
case 5:
// if input is 5
cout<<"V"<<endl;
// exit the switch
break;
case 6:
// if input is 6
cout<<"VI"<<endl;
// exit the switch
break;
case 7:
// if input is 7
cout<<"VII"<<endl;
// exit the switch
break;
case 8:
// if input is 8
cout<<"VIII"<<endl;
// exit the switch
break;
case 9:
// if input is 9
cout<<"IX"<<endl;
// exit the switch
break;
case 10:
// if input is 10
cout<<"X"<<endl;
// exit the switch
break;
// default
default:
break;
}
return 0;
}
Explanation:
Read a number from usr and assign it to variable "num". If the input number is less than 1 or greater than 10 then ask again to enter a number until user enter a number between 1-10 only.Then with the help of switch() function print the equivalent Roman number.
Output:
Enter a number between 1 and 10: -5
Wrong input!!Enter again:12
Wrong input!!Enter again:6
The Roman numeral for 6 is:VI
<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3
Answer:
An engine or motor is a machine designed to convert one form of energy into mechanical energy. Heat engines convert heat into work via various thermodynamic processes.
<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3
JAVA programming was employed...
//IMPORT STATEMENT
import javax.swing.JOptionPane;
public class Payroll
{
//VARIABLE DECLARATION
double grossPay, hoursWorked, payRate;
//INPUT STATEMENT
hoursWorked = Double.paseDouble(JOptionPane.showInputDialog(Please enter your hours worked.));
payRate = Double.paseDouble(JOptionPane.showInputDialog(Please enter the pay rate per hour.));
//PROCESS STATEMENT
grossPay = hoursWorked * payRate;
//OUTPUT STATEMENT
JOptionPane.showMessageDialog(null, grossPay);
}//End of class Payroll
In this program, we declared variables grossPay, hoursWorked, and payRate to double so that the user can input figures with decimal. Since the inputs have decimal, the output which is grossPay will come out with decimal.
But note that inputting numbers doesn't mean that they will be processed as double automatically! For the inputted values to become double, it is important to parse them first that is why the line "hoursWorked = Double.paseDouble(JOptionPane.showInputDialog(Please enter your hours worked.));" and line "payRate = Double.paseDouble(JOptionPane.showInputDialog(Please enter the pay rate per hour.));" were used.
Answer:
See explaination
Explanation:
#include <iostream>
using namespace std;
int main()
{
double h, w;
int s, a, b;
cout<<"height in feet: ";
cin>>h;
cout<<"width in feet: " ;
cin>>w;
cout<<"tile size in inches:";
cin>>s;
int height = h*12;
if(height%s==0)
a = height/s;
else
a = height/s + 1;
int width = w*12;
if(width%s==0)
b = width/s;
else
b = width/s + 1;
cout<<"Number of tiles: "<<a*b;
}