Question 2 Rewrite the following program using a switch-case statement #include int main() { long category; printf("Enter a category number between 50 and 60:"); scanf("%ld",&category); if (catogory >=50 && category <52) printf("It is an elephant"); else if (category >= 53 && category <55) printf("It is a tiger"); else if (category >= 56 && category <58) printf(“It is a leopard"); else printf("It is a strange animal!");
Q: PROBLEM 6: Write a complete program to print the number of days in a given month entered from the…
A: Program plan for the first program: Prompt for the month and year. Define the list of months that…
Q: #include int main() float Bread = 1.09, Water = 2.18, Banana = 1.00, Meat = 7.99; // Unit for bread…
A: Solution: These two line are: //line-1 printf("You have %d loaves of bread, %d bottles of…
Q: Q2: Write a program in C++ to read ten students' name and degrees then calculate the average degree…
A: The program has to be designed as follows: Create arrays for storing names of students. Create…
Q: A small code that returns the average earning of all employees
A: In the program, a function named average is created to return the average earning of all employees.…
Q: Write a multiple assignment statement that can be used instead of the followinggroup of assignment…
A: GIVEN: Write a multiple assignment statement that can be used instead of the followinggroup of…
Q: ASSIGNMENT: Write a C program that will allow the user to enter the inner and outer radii of the…
A: Question given: A formula is given for calculate heat conduction from a cylindrical solid wall of…
Q: Write a C++ . In this program, we want to find the total cost that company X will pay for the…
A: since you have not provided the cost of normal hours(40 hours) so I have written the code only to…
Q: Question #4: Use for statement to write a C program that asks the user to enter a positive integer…
A: Code: #include <stdio.h>int main(){ //declaring required variables int n,i;…
Q: Chargeable Income (RM) Calculation (RM) Rate '% tax(rm) 0 — 5,000 On the First 5,000 0 0…
A: Introduction of the Program: The C program takes a user name and user's chargeable income from the…
Q: 2 a. Write a program to using the principle of control structures (if /else statements) determine…
A: Note: Since the question doesn't mention the programming language use to code so I am using C…
Q: Question #4: Use for statement to write a C program that asks the user to enter a positive integer…
A: C program for above : #include <stdio.h> int main(void) { //prompt user to enter a…
Q: Activity 20 Electric Bill: Using C Language and Using Switch Statement, Make a program that will…
A: Please find the code and output below:
Q: Q /Consider the program below to correct the possible logical errors to produce C program aims to…
A: A list of errors that is previously present was You did not mention the structure name and you…
Q: ASSIGNMENT: Write a C program that will allow the user to enter the inner and outer radii of the…
A: the answer is given below :
Q: QUESTION 3 Rewrite the entire following code segment using a switch statement instead of the if/else…
A: Code: #include <iostream>using namespace std;int main(){ int n,a=1,b=2,c=3,d=4;…
Q: Rewrite the following program using switch statement. #include #include using namespace std; int…
A: The given code is implemented using switch statement:
Q: (De Morgan’s Laws) In this chapter, we discussed the logical operators &&, ||, and !.…
A: According to De Morgan's Law, !(condition1 && condition2) = (!condition1 || !condition2)…
Q: Q3: Write C++ program to read a score of student and print the estimation to refer it. 100-90…
A: Since you have asked multiple questions, according to the company's policy we will solve the first…
Q: Using “c” above, write a program that requests two fertilizer name and their respective yields. Your…
A: - The question is to input two fertiliser and their yield and print the fertiliser with biggest…
Q: Write a C++ program. A software company sells a package that retails for $109. Quantity discounts…
A: To write a C++ program using the if/else if/else statement that asks for the number of units sold…
Q: Question #4: Use for statement to write a C program that asks the user to enter a positive integer…
A: required:
Q: This assignment is to modify the rock-paper-scissors game f. As before, each of two players enters…
A: Program Approach Create an enum variable Choice with the three keys ROCK, PAPER, and SCISSORS with…
Q: 1. Use a functional decomposition to write a C++ program that asks the user to enter his or her…
A: Below i have given program:
Q: Question 1 A cylinder water tank holds x litres of water. the volume of the cylinder is given by v =…
A: A cylinder can be defined as the solid 3D object having two circular faces connected with the…
Q: Question #4: Use for statement to write a C program that asks the user to enter a positive integer…
A: #include <stdio.h> int main() { int num,j=0; printf("\n enter the number"); scanf("%d",…
Q: Mars hyper market gives discount to customers based on their spending. If a customer spends 20 Omani…
A: #include<iostream>using namespace std;int main(){ float spending; cin>>spending;…
Q: C++ program to find the gross salary of an employee using the following structure. Print the details…
A: Introduction of the Program: The C++ program uses a pointer to structure datatype to store all…
Q: Asif buys four products detergent, ghee, milk and soap from Punjab Cash & Carry. You have to write a…
A: Declare variables to store quantity and price Calculate discount of each product Print Discount…
Q: 2.14 LAB: Expression for calories burned during workout The following equations estimate the…
A: as per Bartleby guidelines we are supposed to answer?️ only one question. Kindly repost other…
Q: (b) specify the location of the errors. If you find no error at all, write "No Errors." Find all 5…
A: The given code is below with some errors- 1 #include 2 3 4 class X { 5 public: 6 X(double x): x(x)…
Q: Example 1: Write a C++ program to read student's mark and print "passed" if it is greater than 50.…
A: #include<iostream>using namespace std;int main(){ int mark; cout<<"Enter student's mark:…
Q: What does the following code print out? $cash on hand = 31; $meal = 25; $tax 10; $tip 10; while (…
A: 1) Code in question does below activity It defines below variables and assign them values…
Q: Q1) How to write a C program segment that prompts and accepts the age and number of hours the…
A: define 3 constats i.e childrate=1.00, adultrate=3.50 and seniorRate=2.0 take age and number of hours…
Q: A) Use (switch statement) to write a program in C++ to show company structure. I r is (A), print…
A: Here we need to use switch case on some character input. The syntax for switch case is…
Q: Using C++ write a program Asif buys four products detergent, ghee, milk and soap from Punjab Cash &…
A: Algorithm: Firstly collect the data form the user about the price and quantity then store the total…
Q: Determine whether the following are valid switch statements. if not, explain why. Assume that n and…
A: As per our rules, we should answer only the first 3 parts in a multi-part question. Please submit…
Q: Task 1: In the month of RAMZAN people distribute food packages. Carrefour offers a food package…
A: as the questions you have given are not related to each other and different from each other so as…
Q: Rewrite the following C program using if-else statements. #include int main(void){ int…
A: PROGRAM CODE: #include<stdio.h> // include header file for standard input output int…
Q: A particular talent competition has five judges, each of whom awards a score between 0 and 10 to…
A: To find the average we can find the total sum and then decrease the maximum and minimum and we apply…
Q: The C program shown below is for calculating the area of a circle with a radius of 2.5. However,…
A: #define in C: The #define preprocessor directive is used to define the constant or micro…
Q: Asif buys four products detergent, ghee, milk and soap from Punjab Cash & Carry. You have to write a…
A: Please find the answer below :
Q: PROGRAM DESCRIPTION Make a program that accept employee number, employee name, job code (A/B/C) and…
A: First, we will input the name, job code, number, and hours worked. Based on Job code and hours…
Q: CHALLENGE 3.1.2: Reading multiple data types. ACTIVITY Type two statements. The first reads user…
A: Coded using Python 3.
Q: In the following program, rewrite the line that contains syntax error (errors) in the correct way in…
A: Task :- identify the syntax errors in the code.
Q: How to use C code to write a C program segment that prompts and accepts the age and number of hours…
A:
Q: An Auto Insurance Program Example - Write a C++ program to determine the cost of an…
A: PROGRAM: //Header File #include <iostream> using namespace std; //Defining main int main() {…
Q: c. Refer to the C++ program in Figure 1.1Gad answer Question 1e (1) - (xi). Otinclude tinclude…
A: input radius1 and radius2 it basically calculates the volume of two sphere volume of sphere is =…
Q: Evaluate the following expressions, assume the following declaration: int x = 4; What is…
A: It displays 5.
C
Step by step
Solved in 2 steps with 2 images
- An Auto Insurance Program Example - Write a program to determine the cost of an automobile insurance premium, based on driver's age and the number of accidents that the driver has had. The basic insurance charge is 500 Rs. There is a surcharge of 100 Rs if the driver is under 25 and there is an additional surcharge for accidents as can be seen below: No. of accidents Accident Surcharge 1 50 2 125 3 250 4 375 5 575 6 or more No insurance Note: Use switch cases when you check the total number of accidents.Activity 20 Electric Bill: Using Switch Statement, write a program that will calculate and show bills of the Manila Electric Company. The rates vary depending on whether the use is residential (R), commercial( C) , or industrial (I). Any other code should be treated as an error. The program should accept the subscriber ID, Subscriber Name, his total electrical consumption in a month, and the code of the consumer type. The rates are computed as follows: R: 50 plus .50 per kwh used C: 100 for the first 1000 kwh and 0.45 for each additional kwh I: 180 for the first 1000 kwh and 0.75 for each additional kwh//Below is the starting code for this homework assignment// #include <stdio.h> struct employees { char name[20]; int ssn[9]; int yearBorn, salary; }; struct employees e = {"kim deen", {1,2,3,4,5,6,7,8,9}, 1998, 35000}; void display(struct employees *e) { printf("%s", e->name); printf(" %d%d%d-%d%d-%d%d%d%d", e->ssn[0],e->ssn[1],e->ssn[2],e->ssn[3],e->ssn[4],e->ssn[5],e->ssn[6],e->ssn[7],e->ssn[8]); printf(" %d", e->yearBorn); printf("\n$%d.", e->salary); } int main() { display(&e); return 0; }
- USING C A catalog listing for a textbook consists of the authors’ names, the title, the publisher, and the year ofpublication. Declare a structure type catalog_entry_t and a variable book , and write statements thatstore the relevant data for this textbook in book . I have this code so far but not sure where to go from here #include<stdio.h>#include<string.h> typedef struct{char author_name[50], title[50], publisher[50];int publication;} catalog_entry_t;catalog_entry_t book; strcpy(book.author_name,"Rhett Beeson");strcpy(book.title,"This class is hard");strcpy(book.publisher,"TTU");book.publication=2021An Auto Insurance Program Example - Write a program to determine the cost of an automobile insurance premium, based on driver's age and the number of accidents that the driver has had. The basic insurance charge is 500 Rs. There is a surcharge of 100 Rs if the driver is under 25 and there is an additional surcharge for accidents as can be seen below: No. of accidents Accident Surcharge 1 50 2 125 3 250 4 375 5 575 6 or more No insuranceC++ PROGRAMMING VARIABLE DECLARATION. Create a variable called carName, assign the value Honda to it. Write a C++ assignment statement that assigns the value 23.25 to a float variable named price. Write a C++ assignment statement that assigns the letter T to a char variable named insured. Write the declaration for two variables called feet and inches. Both variables of type int and both are to be initialized to zero in the declaration. Use both initialization alternatives. Write a C++ statement that declares a named constant with identifier name distance and a literal constant value of 14E14.
- # Question 4def costume_rating(costume_color, bling_value): """ Returns a function that calculates the number of candies to return based on the costume color, bling value, and phrase length. Args: costume_color (str): The color of your costume. Must be one of 'blue', 'red', 'green', 'yellow', 'purple', or 'orange'. bling_value (int): Represents how shiny your costume is. Must be a positive integer. Returns: A function that takes in one parameter: phrase (str): The phrase said by the trick-or-treater. >>> costume_rater = costume_rating('blue', 5) >>> costume_rater('19 Character Phrase') 85 >>> costume_rater('e') 0 >>> costume_rater('seven c') 1 >>> costume_rater = costume_rating('orange', 8) >>> costume_rater('hello i want candy') 14 >>> costume_rater = costume_rating('yellow', 5) >>> costume_rater('please give me…ARGUMENT SEVEN Valid ☐ Invalid ☐ No J is B All B is K ∴ No K is J Convert the following argument into symbolic form and then determine whether it is a valid argument by using the Venn Diagram method (include the Venn Diagrams below). ARGUMENT EIGHT Valid ☐ Invalid ☐ No students in COSA 2 who showed up to class finished the reading. A few of them finished the training at home though. It stands to reason that some of the students who showed up to class did not finish the training. Write the argument in Symbolic Form: No M are R Some M are T Some M are not T Venn Diagrams: ARGUMENT NINE Valid ☐ ï Invalid ☐ Anything that is true is a statement and Professor Rosillo makes statements. So, all statements Professor Rosillo makes are true. Write the argument in Symbolic Form: Venn Diagrams:Q1)Further enhance your program below as follows (include a loop structure): • allow data to be continuously input for more customers • After processing the last customer’s order, display a summary report of sales of the day showing details of total number of customers, a summary of each of the packages sold for the day and the total sales value #include <stdio.h> #include <stdlib.h> #include<string.h> #pragma warning(disable:4996) int main(void) { // Variable declarations int t = 0; float k, y, u, i; int a, b, c, d; int p; float add, tt, f; char name[30], ic[20]; char addr[50]; //The personal details of customer // printf("\n========================================================================================================\n"); printf("\n Vegetable ordering system\n"); printf("\n========================================================================================================\n"); printf("Please enter your full name :"); scanf(" %[^\n]", &name);…
- c++ programming if…else and switch case are types of conditional selection statements used in many programming languages such as C++. Write your own codes for question (a), (b) and (c) to demonstrate how the selection statement works. (a) Using if….else selection statement, allow user to key in a number then check whether the number is positive or negative number. (b) Using if….else...if selection statement, allow user to key in a mark for one subject and display the grade for the subject. A for >80, B for >60, C for >50, D for >40, F for <40 .. (c) Using nested if..else selection statement, ask user to key in their age. Then define whether the user should go to nursery, primary school, secondary school or university based on their input. (d) Using switch case selection statement, allow user to key in a mark for one subject and display the grade for the subject. A for >80, B for >60, C for >50, D for >40, F for <40 .This need to be written in c++ Write a program that: Defines an enum named Classification. The enum Classification will have 2 data values: undergraduate, graduate. Defines an enum named Status. The enum Stutus will have 2 data values: parttime, fulltime. Defines an enum named Residency. The enum Residency will have 2 data values: resident, international. Defines a student name variable. Creates a Classification, Status, and Residency, credit hour, cost per credit hour, and tuition variable. Reads the value of the Classification, Status, and Residency, student name and credit hour variable from the user. If the student is a fulltime undergraduate resident student, tuition is credit hour times 345.00 If the student is a fulltime undergraduate international student, tuition is credit hour times 685.00 If the student is a fulltime graduate resident student, tuition is credit hour times 545.00 If the student is a fulltime graduate international student , tuition is credit hour times…Activity 20 Electric Bill: Using C Language and Using Switch Statement, Make a program that will calculate and show bills of the Manila Electric Company. The rates vary depending on whether the use is residential (R), commercial( C) , or industrial (I). Any other code should be treated as an error. The program should accept the subscriber ID, Subscriber Name, his total electrical consumption in a month, and the code of the consumer type. The rates are computed as follows: R: 50 plus .50 per kwh used C: 100 for the first 1000 kwh and 0.45 for each additional kwh I: 180 for the first 1000 kwh and 0.75 for each additional kwh