Concept explainers
Explanation of Solution
a.
Program:
//Import necessary header files
import java.util.*;
//Define the class
class Main
{
//Define the main() method
public static void main(String[] args)
{
//Initialize the variable x as 4
int x = 4;
//Check the condition
if (x > 5)
//True, Print A
System.out.println("A");
//Check the condition
else if (x < 10)
//True, Print B
System...
Explanation of Solution
b.
Program:
//Import necessary header files
import java.util.*;
//Define the class
class Main
{
//Define the main() method
public static void main(String[] args)
{
//Initialize the variable x as 5
int x = 5;
//Check the condition
if (x > 5)
//True, Print A
System.out.println("A");
//Check the condition
else if (x < 10)
//True, Print B
System...
Explanation of Solution
c.
Program:
//Import necessary header files
import java.util.*;
//Define the class
class Main
{
//Define the main() method
public static void main(String[] args)
{
//Initialize the variable x as 6
int x = 6;
//Check the condition
if (x > 5)
//True, Print A
System.out.println("A");
//Check the condition
else if (x < 10)
//True, Print B
System...
Explanation of Solution
d.
Program:
//Import necessary header files
import java.util.*;
//Define the class
class Main
{
//Define the main() method
public static void main(String[] args)
{
//Initialize the variable x as 9
int x = 9;
//Check the condition
if (x > 5)
//True, Print A
System.out.println("A");
//Check the condition
else if (x < 10)
//True, Print B
System...
Explanation of Solution
e.
Program:
//Import necessary header files
import java.util.*;
//Define the class
class Main
{
//Define the main() method
public static void main(String[] args)
{
//Initialize the variable x as 10
int x = 10;
//Check the condition
if (x > 5)
//True, Print A
System.out.println("A");
//Check the condition
else if (x < 10)
//True, Print B
System...
Explanation of Solution
f.
Program:
//Import necessary header files
import java.util.*;
//Define the class
class Main
{
//Define the main() method
public static void main(String[] args)
{
//Initialize the variable x as 11
int x = 11;
//Check the condition
if (x > 5)
//True, Print A
System.out.println("A");
//Check the condition
else if (x < 10)
//True, Print B
System...
Want to see the full answer?
Check out a sample textbook solutionChapter 3 Solutions
Java: An Introduction to Problem Solving and Programming (8th Edition)
- Problem You have code that needs to perform simple time conversions, like days to seconds, hours to minutes, and so on.arrow_forwardjava programarrow_forwardC++ Assignment: In India McDonald's has the n number of customers and they are famous for their taste and quality so they plan to Organise the challenge for foody people. What is the challenge is? you have taken a food challenge from the Chef and now you have to eat directly the Y burgers. You will eat as follows: At the first minute you will eat exactly the X burgers and every minute after that you will eat twice the number of burgers you ate the minute before. As you can get tired of food, Chef also lets you take a break from eating for one minute. When you start eating again after a break, your food streaks are reset, which means that in the first minute after the break you will eat X burgers and every minute after that you will eat the burgers you ate twice the last minute. Allow a1, a2, ., let it be your meal length in minutes. The cook needs to have all the ai different in pairs. Get the minimum number of minutes you need to eat Y burgers directly or decide that it is not…arrow_forward
- c++ Write a program to use enumeration type to represent the seven colors of the rainbow, i.e. red, orange, yellow, green, blue, indigo and violet, as the enumerators in sequence, and red starts from 1. Then, ask the user to choose a value between the range of 1 – 7. If the user enters 3, the output will tell the user yellow has been chosen, and also display the previous and next colors of the chosen colors. If the user enters 1 or 7, display the chosen color and only next/previous color is displayed accordingly. Write the program in an infinite while loop, until a number which is beyond the range of 1 – 7 is entered. The sample output is as follows, Enter a number in the sequence of the rainbow color (1-7): 7 Violet is chosen. The previous color is indigo. Enter a number in the sequence of the rainbow color (1-7): 1 Red color is chosen. The next color is orange. Enter a number in the sequence of the rainbow color (1-7): 3Yellow is chosen. The previous color is orange and next…arrow_forwardint f(int &k){k++;return k * 2;}int main(){int i = 1, j = -1;int a, b, c;a = f(i) + i/2;b = j + f(j) + f(j);c = 2 * f(j);return 0;} What are the values of a, b and c id the operands in the expressions are evaluated from left to right and then what are the values when its evaluated right to left?arrow_forwardC++ - No library functions like atoi Write a machine language program to output your first name on the output device. Submit your "machine code" followed by a 'zz.' An example of the machine code to output "hello" is shown below. This is an example of what a machine language submission would look like: 50 00 48 50 00 65 50 00 6c 50 00 6c 50 00 6f 00 zzarrow_forward
- Question Using Java programming language write a program to manage a hotel with 24 rooms;10 rooms are Executive, with price Gh ₵ 2500.00 per night,7 rooms are Chalets, with amounts Gh ₵ 1500.00 per night7 rooms are Ordinary, with amount Gh ₵ 500.00 per night The program should allow customers to book for rooms for a number of nights, and update the number of empty rooms available for each category when a customer has paid fully and has checked-in; also update the number of empty rooms available when customer checks-out.Customers should make bookings with their first names, telephone number A customer should be prompted to know if a room is booked (meaning a another customer has booked it but has not paid fully, or has not checked-in) A customer should be prompted to know if a room is occupied (meaning a booked room has been fully paid for, or the customer has checked-in) A customer should be prompted to know if a room is available (meaning a room has neither been booked nor…arrow_forwardC - Right Facing Anglearrow_forward3- Enter a=3; b=5; e=7, then clear the variable b only Matlabarrow_forward
- For each function prototype, find the valid return statement. int MyFunction(char r, int a); A. return; char MyFunction(int a, char r); + void MyFunction(int a, int b, int c); float MyFunction(char r, int d, double x); double MyFunction(int a, int b); B. return 1; C. return '9'; D. return 6.00; E. return 5.2f;arrow_forwardCode and outputarrow_forwardHhhQuiz score: 80 Mid-term score: 68 Final score: 90.arrow_forward
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning