Answer:
The program to this question can be describes as follows:
Program:
#include <iostream> //defining header file
using namespace std;
int main() //defining main method
{
float user_num ;//defining float variable
cout<<"Enter any number: "; //message
cin>>user_num; //input value from the user
while (user_num >= 1) //defining loop to calculate value
{
user_num =user_num/ 2; //diving the value
cout<<user_num<<endl; //print value
}
return 0;
}
Output:
Enter any number: 20
10
5
2.5
1.25
0.625
Explanation:
In the above program, a float variable user_num is declared in which we store input value from the user end, in the next step, a while loop is declared, which calculates, the given value.
- In the loop a condition is defined, that user_num value is greater than equal to 1, inside the loop it will divide the value of the user_num and store in this variable.
- In this print, the method is used, which prints its variable values.
Answer:
3
Explanation:
ER model can be used and is based on three basic concepts: Entities, Attributes & Relationships.
An entity can be place, person, object, event or a concept, which stores data in the database.
Relationship is nothing but an association among two or more entities. A weak entity is a type of entity which doesn't have its key attribute.
Answer:
import java.util.Scanner;
public class Speed{
int speed;
public Speed(int speed){
this.speed = speed;
}
public void checkSpeed(){
if(speed >= 24 || speed <= 56){
System.out.println("Speed is normal");
}
else
System.out.println("Speed is abnormal");
}
public static void main(String...args){
Scanner input = new Scanner(System.in);
int userSpeed = 0;
System.out.println("Enter a speed: ");
userSpeed = input.nextInt();
Speed obj1 = new Speed(userSpeed)
obj1.checkSpeed();
}
Explanation:
Answer:
Answered below
Explanation:
// Python implementation
incrementAmount = 5
basePrice = 10
price = 0
arrivalHour = int(input("Enter arrival hour 0-12: ")
if arrivalHour < 0 or arrivalHour > 12:
print ("Invalid hour")
if arrivalHour == 0:
price = basePrice
else:
price = arrivalHour * incrementAmount
totalPrice = price + basePrice
if totalPrice > 53:
totalPrice = 53
print ("Your bill is $totalPrice")