PART 1. EXAMINE THE FF. CODE int numValue =2; int answer =0; switch(numValue){ case 1: answer +=1; case 2: answer +=2; case 3: answer +=3; break; case 4: answer +=4; case 5: answer +=5; default: answer =0; break; } cout <<”Answer: ” << answer << endl; 1. What is the answer(output) if the value of numValue is 2
Q: Provide the equivalent UML Diagram for this code.
A:
Q: syntactical/logical error(s
A: div() function: In C++, the predefined div() function returns the remainder and quotient of the…
Q: Write a program in C++ object oriented programming Create a class Class1 with a string data member…
A: C Program:- #include <iostream>#include <string>#include <fstream>using namespace…
Q: The Course class The modifications you will apply to the Course class are shown in the following UML…
A: Course.java import java.util.Arrays; import java.util.Scanner; public class Course {…
Q: 7. In dynamic programming, the technique of storing the previously calculated values is called a)…
A: The problem is based on the basics of dynamic programming and algorithms.
Q: class Test { char paper[20]; int marks; public: Test () // Function 1 { strcpy (paper, "Computer");…
A: 1) Statements in C++ that would execute Function 1, Function 2, Function 3 and Function 4 of class…
Q: Programming knowledge is based on the programmer’s experience with various standard structures,…
A: Code public class Raintal{public static void main(String []args){Customer[] c = new…
Q: In C++ class film { public: void setFilmDirector(string s); //sets the filmTitle to s…
A: In the given code printAllFilmInfo() prints the information about each film object…
Q: Assignment: Class, Constructors, Destructors 1. Write a c++ program that uses that has a class…
A: #include<iostream>#include<stdio.h>#include<string.h>#include<cstdlib>using…
Q: Write a c++ oop code following these instructions only. Class Scene: capture_date : int draw() :…
A: // This program is a trivial little flight simulator. You control a ship // with the keyboard. Use…
Q: In this laboratory work, you are expected to write a c# console application to make some operations…
A: Code: using System;using System.Collections.Generic;// using System.Linq; class Food{ int…
Q: This code is for c++ Write the Program for both the .h and the .cpp for the UML diagram Account…
A: Account.h code: #ifndef AccountH #define AccountH #include <iostream> using namespace std;…
Q: A reference parameter is a formal parameter that receives the memory address of its corresponding…
A: When we pass address in function it is then known as call by reference function.
Q: Output Example Default Constructor: 0/1 Single Parameter Constructor: 2/1 Dual Parameter…
A: A C++ program for the given criteria is as follows, File name: “main.cpp” #include <iostream>…
Q: The push member function simulates the push of a numeric button with value 0 to 9. The open member…
A: C++ is a powerful general-purpose programming language which can be used to develop operating…
Q: PART I: Given the following UML diagram. Answer the following questions PCRTest newNum: int //--…
A: In class PCRTest, newNum is a static data member whose value is incremented by one each time an…
Q: Textbook: Joyce Farrell, Microsoft® Visual C#®: An Introduction to Object-Oriented Programming,…
A: Given: C#code is given that has errors in it. Required: Find the error and correct the code.…
Q: In C++ or pyhton Design and code a class as described in the following diagram BankAccount…
A: The solution is done using C++. Please refer to the following step for the complete solution to the…
Q: ++ question 1 Monitor class header file: Monitor.h Instructions: 1. Code the class…
A: The given problem is to be solved in C++ language where a header file named Monitor.h is to be…
Q: Defines an enum named Classification. The enum Classification will have 2 data values:…
A: I have answered this question in step 2.
Q: 1. Input(): Ask user to provide values for color and fuel. Default values for speed is “0” and state…
A: the code is an given below : import java.util.Scanner; public class Vehicle { Scanner sc; //…
Q: Rule Base case: x₁ = 2 X1 Xn = Xn-1-3n² Predicate reccurrence Rule 2
A: xn=xn-1-3n2 => xn= xn-2-3(n-1)2-3n2…
Q: Write the c++ class interface code that is presented by the following UML diagram OOPstudent…
A: The following C++ code is based on given class diagram. Include necessary headers to program Make a…
Q: In CPP , Write a program that: Defines an enum named Classification. The enum Classification will…
A: Here I have created 3 different enums. Next, in the main method, I have taken input from the user…
Q: PART I: Given the following UML diagram. Answer the following questions PCRTest newNum: int //--…
A: In class PCRTest, newNum is a static data member whose value is incremented by one each time an…
Q: Create a program that has the following requirements: 4.1 menu driven program that…
A: To create a program that meets the following requirements: Conditional structure; Looping;…
Q: Write a program that: Defines an enum named Classification. The enum Classification will have 2 data…
A: Please upvote me Please. I need it badly. Please. Please. I am providing the required code in…
Q: In LISP, the function returns t if is a CONS cell and nil otherwise: A. (cons ) B. (consp ) C. (eq…
A: We need to find in LISP, which function returns t if <object> is a CONS cell and nil…
Q: A point in the x-y plane is represented by its x-coordinate and y-coordinate. Design a…
A: Constructor is a method which have same name as class name and whenever the instance is created,…
Q: You are asked to write a C console application that implement a system for a simple training center.…
A: the codes is an given below :
Q: Exercise on class inheritance in C++. General requirements: • All data members must be declared as…
A: #include <iostream>#include <string.h>using namespace std; class BooleanVariable{…
Q: Q2. Please convert the following UML class diagram into a C++ class declaration. CAR -…
A: Introduction : Here we have to convert the given following UML class diagram into a C++ class…
Q: Formal and actual parameters are matched up bya) name b) position c) ID d) interests
A: Let's see the solution
Q: PROBLEM: Re-order for the correct code sequence by filling the blank with the CORRECT line number(#)…
A: Default constructor of a class is executed when the object of the class is created without giving…
Q: Cyclomatic complexity is? a. White-box testing method b. Black box testing c. Requirement analysis…
A: Introduction: Cyclomatic complexity is a metric devised by Thomas McCabe to assess a program's…
Q: The assignment operator (-) and the equivalence operator (--) are interchangeable, but they will…
A: The problem is based on the basics of operators in programming languages.
Q: Some things such as if constructs may be nested. Two if constructs are said to be nested if one of…
A: The problem is based on the basics of conditional statements in programming languages.
Q: Language is c++ Assignment 6 C: Minesweeper - Simplified. For many years, computers sold with the…
A: Algorithm: Start Read size of grid n Initialize an array 'a' of size n*n with '?' Generate 3 random…
Q: Based on the given class diagram, create a class implementation using C++. Voters -active_Account:…
A: GIVEN:
Q: In a programming language that binds variables to a specific data type if the variable is named in a…
A: According to the information given:- We have to find out In programming language binding variable to…
Q: An argument is expressed in English below. The domain is the set of people attending a party. Every…
A: Task : Given the set of sentences. The forms of the argument of these sentences. The task is to…
Q: Can
A:
Q: Scheme - For the following questions, write the value that the expression evaluates to if you type…
A: Note: - As per our guidelines we can only answer one question at a time. Please resubmit the other…
Q: In a programming language that binds variables to a specific data type if the variable is named in a…
A: In a programming language that binds variables to a specific data types if the variables is named in…
Q: (Write C++ Code) 1. Monitor class header file: Monitor.h Instructions: 1. Code the class…
A: Given: Monitor class - Monitor.cpp Instructions: Code the class cpp file and name it as Monitor.cpp.…
Q: Write a function, In c++ that takes two of those points, and returns the distance between them.
A:
Q: (Write C++ Code) (computer science) 1. Monitor class header file: Monitor.h Instructions:…
A: You have asked multipart question so we will solve the three questions for you, those will be…
Q: to print the name, age , class, school and email of 4 students. if the email is not provided, print…
A: import java.util.Scanner; public class Student { //member variables String name; String email;…
Q: Q.No.2. Write the code for the following UML diagram. Vehicle -color:String -speed:double…
A: The Unified Modeling Language (UML) is a standard visual modeling language, operational design…
Q: Consider the following pseudocode, then write the pseudocode for mainline. class Weapon…
A: Instance variables are the variables that are independent for every object that we generate The…
PART 1. EXAMINE THE FF. CODE
int numValue =2;
int answer =0;
switch(numValue){
case 1: answer +=1;
case 2: answer +=2;
case 3: answer +=3;
break;
case 4: answer +=4;
case 5: answer +=5;
default: answer =0;
break;
} cout <<”Answer: ” << answer << endl;
1. What is the answer(output) if the value of numValue is 22? ____________________
2. What is the answer(output) if the value of numValue is 1? ____________________
3. What is the answer(output) if the value of numValue is 4? ____________________
4. What is the answer(output) if the value of numValue is 2? ____________________
5. Is break statement in the default case needed? Why or why not? Explain.____________________
Step by step
Solved in 4 steps
- In C++ or pyhton Design and code a class as described in the following diagram BankAccount name: string balance: double name: string balance: double BankAccount() BankAccount(string, double) getName():string getBalance():double setName(string):void setBalance(string):void deposit)double=:void withdraw(double):boolean sample()Language is c++ Assignment 6 C: Minesweeper - Simplified. For many years, computers sold with the Windows operating system would contain a game called M inesweeper. The player would be presented with a grid, where they would have to click an empty part of the map. If they clicked on a hidden mine, the game would be instantly over. However, if they clicked a safe spot, a hint about nearby mines would be displayed and the player would click another spot. The goal would be to flag all the hidden mines without hitting one. (As an aside, many people did not know these rules and just clicked around randomly until they hit a mine)We will be developing a simplified version of this game. You will prompt the user for a grid size and then created a 2D array with equal width and height (C++ students: Check the Appendix for more information on how to do this). You will initialize the 2D char array with each element equallying a ‘?’ symbol. You will then randomly generate one “mine” value per…class Test { char paper[20]; int marks; public: Test () // Function 1 { strcpy (paper, "Computer"); marks = 0; } Test (char p[]) // Function 2 { strcpy(paper, p); marks = 0; } Test (int m) // Function 3 { strcpy(paper,"Computer"); marks = m; } Test (char p[], int m) // Function 4 { strcpy (paper, p); marks = m; } }; i. Write statements in C++ that would execute Function 1, Function 2, Function 3 and Function 4 of class Test. ii. Which feature of Object Oriented Programming is demonstrated using Function 1, Function 2, Function 3 and Function 4 together in the above class Test?
- Formal and actual parameters are matched up bya) name b) position c) ID d) interestsConsider the following pseudocode, then write the pseudocode for mainline. class Weapon Declaration String make String model String serialNumber String countryOfOrigin void setMake(string manufacturer) set make = manufacturer return string getMake() return make endClass Q.4.3.1 Declare each of the instance variables and include an object forthe class in the mainline logicPlease solve usnig c++ programming language. Number Converter Program as described in the UML has the following functionality.1. Read a number from the user and find its base. If number is exceeding the limit of 16-bits,ask user to re-enter the number. Use parameterized constructor Conversion(char *) toinitialize the data member.int FindBase(char []);There are a few assumptions. i) If all digits of a number are 0 or 1, the number is binary. For example, 1010 will beconsidered a Binary number only.ii) A hexa-decimal number must have letter A, B, C, D, E or F. Otherwise the number willnot be considered a hexa-decimal.iii) Decimal number must have minimum one digit greater than 7. Otherwise, the numbercan be considered as Octal if it does not meet the criteria in point no. i and ii.2. Converting the number to Binary if the number is not Binary.char * ToBinary(char *);3. Converting the number to Octal if the number is not Octal.char * ToOctal(char *);4. Converting the number to…
- Help, I making a elevator simulator. I have to use polymorphism and object oriented programming to write this code. Can someone please help me improve this code I have. The remaining code is in the pictures. Any help is appreciated. Thank You! The simulation should have 4 types of Passengers: Standard: This is the most common type of passenger and has a request percentage of 70%. Standard passengers have no special requirements. VIP: This type of passenger has a request percentage of 10%. VIP passengers are given priority and are more likely to be picked up by express elevators. Freight: This type of passenger has a request percentage of 15%. Freight passengers have large items that need to be transported and are more likely to be picked up by freight elevators. Glass: This type of passenger has a request percentage of 5%. Glass passengers have fragile items that need to be transported and are more likely to be picked up by glass elevators. The simulation should also have 4 types…ll data members must be declared as private. Global variables are not allowed. Constants are ok. There should be no usage of cin or cout in the method or in the class definition or required functions. They should be handled using parameters and return values. cin and cout can and should be used in the testing functions. There should be only one “return” statement in a function or method. Multiple return statements within the same function/method are not allowed. Please pay attention to the required data types in the description. tuple, list and vector classes are not allowed to be used in this exam. Please write C++ functions, class and methods to answer the following questions. 1. Define a new C++ class named “Exam” that manages simple exam information: student id (integer) and a score (integer) The class must provide at least the following two methods: • isPassing which will return a boolean: true if the score is >=60 and false otherwise • toString method that returns the string…Write the code for the following UML diagram.Vehicle -color:String-speed:double-fuel:double+state: String+input():void+addFuel(): double+moving():void+stop():void+display():void 1. Input(): Ask user to provide values for color and fuel. Default values for speed is “0”and state is “stopped”2. addFuel(): Ask user to provide value for fuel to add. Add that value in fuel (attribute)and return value of total fuel.3. moving(): Ask user to provide the speed of vehicle and fuel consumption. Set the valueof speed and reduce the fuel (attribute) according to fuel consumption. And also set thestate to “Moving”.4. stop(): This method will display that “Vehicle is stopped” and sets the value of speedto “0” and state to “Stopped”5. display(): This method will display the attributes value to output like:“Vehicle is stopped. It has red color. It’s speed is 0.0 and fuel is 2.5 Liter”
- C++ question 1 Monitor class header file: Monitor.h Instructions:1. Code the class specification file and name it as Monitor.h. You can code the constructor initialization steps in-line. The rest of the member functions should just be prototypes. The class specification should define the prototypes of each functions. Class name: MonitorPrivate Member Attributes: string brand string model int width (px) int height(px) int ppi double refreshRate (hz) char speakers (Y/N) int ports (no. of ports) string portType (list of port types separated by commas) Public Member Inline Functions Default Constructor with no parameters will initialize all numeric variables to 0. Constructor that accepts 3 int parameters for width, height, ppi. This constructor defaults the brand to "Generic", model to "Basic", the refreshRate to 60, speakers to 'N', ports to 1, and portType to "HDMI". Destructor (empty destructor) Public Member Functions as Prototypes: Prototype for Setters…In CPP , 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 885.00 If the student is a…In C++ class film { public: void setFilmDirector(string s); //sets the filmTitle to s void setFilmYear(string year); //sets the private member filmYear to year void setFilmProdCost(double cost); //sets the private member filmProdCost to cost void setFilmGenre (string type); //sets the private member filmGenre to type void printAllFilmInfo() const; //prints the filmDirector, filmYear, the filmProdCost and the filmGenre string geFilmGenre() const; //returns the filmGenre string getFilmYear() const; //returns the filmYear double getFilmProdCost() const; //returns the filmProdCost void updateFilmProdCost(double cost); //adds cost to the filmProdCost, so that the filmProdCost now has it original value plus the //parameter sent to this function private: string filmDirector; string filmYear; double filmProdCost; string filmGenre; }; Assume the following in your main program (the…