I would really appreciate if someone helps me out with this C++ assignment; Ques
ID: 3910104 • Letter: I
Question
I would really appreciate if someone helps me out with this C++ assignment;
Question 1: Write an if statement that assigns 65 to num2 when num1 is equal to 13
Quesiton 2: Write an if-else statement that assigns 19.2 to y when x is less than or equal to 1.5, otherwise assigns 38.4
Question 3: Using the following chart, write an if-else-if statement to calculate the commission amount depending on the value in sales as below:
Question 4: Write nested if statement that performs the following: If amount1 is greater than 2500 and amount2 is greater than or equal to 1500, if amount1 is less than amount2 then display the “Amount2 is greater than 2500”
I would really appreciate if someone helps me out with this C++ assignment;
Question 1: Write an if statement that assigns 65 to num2 when num1 is equal to 13
Quesiton 2: Write an if-else statement that assigns 19.2 to y when x is less than or equal to 1.5, otherwise assigns 38.4
Question 3: Using the following chart, write an if-else-if statement to calculate the commission amount depending on the value in sales as below:
Sale amount Commission Rate Over $22,000 5% Greater $12,000 to $22,000 3% Less than or equal $12,000 2%Question 4: Write nested if statement that performs the following: If amount1 is greater than 2500 and amount2 is greater than or equal to 1500, if amount1 is less than amount2 then display the “Amount2 is greater than 2500”
Question 5: Convert the following if-else-if statement into a switch statement if (select == 1 || select == 2 ) { System.out.println(“You selected 1 or 2”); else if (choice == 3) { System.out.println(“You selected 3.”); } else if (choice == 4 ) { System.out.println(“You selected 4.”); } else { System.out.println(“Select again please.”); }Explanation / Answer
Answer is as follows :
According to Chegg Guidelines we are allowed to provide answer of First Four questions, So please repost others.
Ques 1 :Write an if statement that assigns 65 to num2 when num1 is equal to 13 ?
Answer :
if (num1 == 13) // check if num1 is 13
{
num2 = 65 ; // assign value
}
Quesiton 2: Write an if-else statement that assigns 19.2 to y when x is less than or equal to 1.5, otherwise assigns 38.4
Answer :
if(x <= 1.5) // check x is less than or equal to 1.5
{
y = 19.2
}
else
{
y = 38.4; // set if condition false
}
Question 3: Using the following chart, write an if-else-if statement to calculate the commission amount depending on the value in sales
Answer:
if(Sales_amount > 22000) // check if sales amount > 22000
{
commision = (5 * Sales_amount) / 100 ; // calculate commision
}
else if(Sales_amount > 12000 || Sales_amount <= 22000) // check sales amount between 12000 and 22000
{
commision = (3 * Sales_amount) / 100 ; // calculate commision
}
else // if less than or equal to 12000
{
commision = (2 * Sales_amount) / 100 ; // calculate commision
}
Question 4 :Write nested if statement that performs the following: If amount1 is greater than 2500 and amount2 is greater than or equal to 1500, if amount1 is less than amount2 then display the “Amount2 is greater than 2500”
Answer :
if(amount1 > 2500 && amount2 >= 1500)
{
if(amount1 < amount2)
{
cout << "Amount2 is greater than 2500";
}
}
I will provide only statements, not full program, if you want fulll program let me know..
// are comments...
if there is any query or you want other parts please ask in comments...