Examine the following code segment and consider what variable bindings will be visible at various points in the program under both STATIC and DYNAMIC scoping. 01 int h, i; 02 03 void B(int m) { 04 int j, k; 05 // what is visible HERE? 06 ... 07 } 08 09 void A(int j, int k) { 10 float h = j + k; 11 B(h); 12 ... 13 } 14 15 void main() { 16 int i, j; 17 18 A(h, i); 19 B(h); 20 ... 21 }
Q: 3. Construct a simple purchasing program based on the UML Class Diagram below. LabExer2 itemName:…
A: The program will encapsulate the data and bind data and method. Data encapsulation is taking place.…
Q: Consider the following C program void fun(void) int a, b, c/* definition 1/ while C.J int b, c, d;…
A: Please find Re-vised code below:
Q: Consider the following program listing and assume it is run as a module. 1 def main() -> None: 2 х3D…
A: EXPLANATION: The first command that gets executed is the outermost line that is the if condition.…
Q: What is the output of the following program? (You may wish to draw a structure diagram first.)1…
A: What is the output of the following program? (You may wish to draw a structure diagram first.)1…
Q: Specify true (T) or false (F) for each of the following statements. (a) In dynamically typed…
A: Note: As per our guidelines, we are allowed to answer the first three questions of multi parts…
Q: write a c++ program with following instructions A Car is composed of four Wheel thingies. If a car…
A: Program is made as per the above instructions. Declared classes with functions Main function is…
Q: Write in C++ a program that would print the information (name, year of joining, salary, address) of…
A: C++ code is as follows :
Q: 3. Write a java program using Encapsulation for the following class diagram. Get the values of name,…
A: Aim: To write a java program using Encapsulation for the following class diagram. Get the values of…
Q: Dry run the below programs and explain the reasons of output. If there is any error then correct…
A: EXPLANATION class access{ public int x; static int y; // all static variables are common for all…
Q: QUESTION 3: Advanced Java Programming Analyse the following Java code segment and answer the…
A: Problems are in line number 4, 10 and 11
Q: For the eight Java statements below, identify each of the following statements as legal or illegal,…
A: For the given Java statements, we need to identify each statement as legal or illegal, and state…
Q: Write a java program using Encapsulation for the following class diagram. Get the values of name, id…
A: Student.java ======================= import java.util.Scanner; public class Student { //declaring…
Q: Considered the following code (excution begins in main ) What is the output of the code int i = 1,…
A: Solution: Given,
Q: n Software Design Principle, this could be described as potential violation of____design principle,…
A: Given that design does not allow it's behavior to be further extended without modifying source code.…
Q: Explain encapsulation and inheritance with suitable examples.
A: As per our guidelines we are supposed to answer only the first question. I request you to post the…
Q: Consider the program below. What is the output of the program when it is:
A: Given code: int i=25; void A(void) { printf("A1: %d \n",i); i--; printf("A2: %d \n",i); }…
Q: write a C++ program to Create a class Bank_System which hold information regarding customer.…
A: Note: Program designed based on procedure mentioned in the question. code: #include<iostream>…
Q: 3. Write a java program using Encapsulation for the following class diagram. Get the values of name,…
A: Java-Encapsulation: It is a process of Wrapping of code and data together into a single unit. In…
Q: The following program is written in a new progr and executes without any errors. Its output is the…
A: Sol: we have given one program pseudo code and based on such given code we will answer in the given…
Q: QUESTION 3: Advanced Java Programming Analyse the following Java code segment and answer the…
A: Below is the answer:
Q: Create a class Time which contains: ● Hours Minutes Seconds Write a C++ program using operator…
A: In C++, we can change the way operators work for user-defined types like objects and structures.…
Q: Q1) Explain in your own words the difference between Explicit and Implicit Type Casting concept in…
A: Implicit Type Casting : An implicit type casting can be seen when the JAVA compiler automatically…
Q: Consider the following JavaScript skeletal program: //The main program var x; function sub1() {…
A: In the given code two var x are declared. One var x is declared in the main and the second var x is…
Q: 3. Write a java program using Encapsulation for the following class diagram. Get the values of name,…
A: Answer: import java.util.* ; //import the required package//define the Student classclass…
Q: QUESTION 3: Advanced Java Programming Analyse the following Java code segment and answer the…
A: 1st error is Input Y is an array type so we have to assign it as array.( [. ] Y)
Q: c# program Create a class Human which should have functionalities for Walk and Run taking an integer…
A: C# associates almost everything with objects and class. C# allows method overloading that is the…
Q: Note: The code should be in Java Programming) Suppose a business person launches new cinema at…
A: When we need a resizable array other than the built-in array of fixed length we use ArrayList of…
Q: Employee'
A: Step 1 - Include the required header files (iostream.h, conio.h, and windows.h for colors). Step 2 -…
Q: Write C++ program, two object of that type (Sub1 and sub2) with three members (A, B, C) to calculate…
A: You can use an array to store all the values of A, B, C of two objects
Q: 3. Consider the following cl- definition and output the resu public class Children (String name; int…
A: // A Java program to demonstrate that non-method // members are accessed according to reference //…
Q: Is the static block always run execute first in java. Explain it with java code. Considering a class…
A: Required:- Is the static block always run execute first in java. Explain it with java code.…
Q: Exercise01. Write a Java program to define and call CalculateAreaCylinder(double height, double…
A: public static double CalculateAreaCylinder(double height, double radius) { double area; area =…
Q: With regard to the following JavaScript program, function main() { function sub1() var x = 10;…
A: answer is
Q: Exercise 10 Automatic type conversion is called coercion. For example, if an int variable and a…
A: Given: Automatic type conversion is called coercion. For example, if an int variable and a float…
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: Analyse the following Java code segment and answer the questions that follow: 1| long 1LongNumber =…
A: The rules for valid identifier are It should contains letter, numbers , underscore and dollar…
Q: (d) Analyse the following Java code segment and answer the questions that follow: 1| long…
A: Identifiers in Java are symbolic names used for identification. They can be a category name,…
Q: a) The Covid-19 Booster Vaccination. program. Write a structured Java program (without using…
A: Let's understand step by step : 1. First declare a string variable type_of_vaccine and an integer…
Q: Write the output of the following C++ code. Also, write the name of feature of Object Oriented…
A: Here we have written the function Line with different numbers and types of parameters. Then, in the…
Q: ll classes must be declared inside of the main function A) True B) False
A: Solution is given below :
Q: 2- Write C++ program to create class name ration card enter the information, quantity for ration…
A: In this question, we are asked to write a ration card class and fill 7 items with 2 object and print…
Q: Given the following code snippets, convert the program into a class and an application by applying…
A: Use an abstract class and have getters and setters for the instance variables for abstraction and…
Q: Enter the name of the item you purchasing. bag Enter the quantity and price separated by a space. 3…
A: Create a header file. Inside the main function declare the function for the input of items name and…
Q: (1) Write a C++ program using the following class details: Class Name: Employee public: - void…
A: Hey there, I am writing the required solution based on the above given question. Please do find the…
Q: Read the following JAVA program and answer the questions given at the end.
A: (a) In class Example, there are two types of data members: Instance or non-static data members int…
Q: identify the following as better representing static or dynamic binding. a) an int is an int…
A: The Answer is in step2
Q: Consider the following Statements: A. In C++, when a variable is declared and given a type, there is…
A: Answer the above questions are as follows:
Q: write c++ program to create class 'airplanes' has public string "types " and int value "model" to…
A: #include <iostream>#include <string> using namespace std;//class for airplanes class…
Q: (3) Write a Java program that prompts the user to enter a sentence (phrase), then it counts how many…
A: Please find the answer below :
Q: 05: Consider the following Java program: public void fun(void) { int a, b, c; /* definition 1 */ ...…
A: The java program: public void fun(void) { int a, b, c; /* definition 1 */ . . . while (.…
Examine the following code segment and consider what variable bindings will be visible at various points in the
01 int h, i;
02
03 void B(int m) {
04 int j, k;
05 // what is visible HERE?
06 ...
07 }
08
09 void A(int j, int k) {
10 float h = j + k;
11 B(h);
12 ...
13 }
14
15 void main() {
16 int i, j;
17
18 A(h, i);
19 B(h);
20 ...
21 }
Step by step
Solved in 2 steps
- main.cpp 1 @include 2 using namespace std; int maxResult() 4-( int maxVal = 0; 6. for (int i = 0; i <= n; i += a) { for (int j = e; j <= n i;j += b) !! 10 (float)(n - (i + j)) / (float)(c); 11 float z = 12 if (floor (z) { int x = i / a; int y 13 ceil(z)) 14 15 16 j/ b; max (maxVal, x + y + (int)z); 17 maxVal = 18 19 20 21 22 return maxVal; 23 } 24 int main() 26 { 25 27 28 cout << maxResult( ); 29 30 return 0; 31 } Input Compilation failed due to following erors) main.cpp:7:23: error: 'n was not declared in this scope 7 for (int i = 0; i <= n; i t a) main.cpp:7:31: error: 'a' was not declared in this scope 7 for (int i 0; i <= n; i t a) main.cpp:9:36: error: 'b' was not declared in this scope for (int j = 0; j <- n i; j b) %3D main.cpp:11:45: error: was not declared in this scope#include<stdio.h> #include<stdarg.h> void fun1(int num, ...); void fun2(int num, ...); int main() { fun1(1, "Apple", "Boys", "Cats", "Dogs"); fun2(2, 12, 13, 14); return 0; } void fun1(int num, ...) { char *str; va_list ptr; va_start(ptr, num); str = va_arg(ptr, char *); printf("%s ", str); } void fun2(int num, ...) { va_list ptr; va_start(ptr, num); num = va_arg(ptr, int); printf("%d", num); }.3).class jump_statments { public static void main(String args[1) { int x = 2; int y = 0; for (; y < 10; ++y) { if (y % x 0) == continu e; else if (y 8) break; == else %3D System.out.print(y + " "); } a) 1357 b) 24 68 c) 1 3579 d) 1234 5 6 7 8 9
- For the C++ program show on the next page, answer the questions that follow. The names g, j, x, and y are declared multiple times. Distinguish uses of these names using line numbers where they were declared as subscripts. a. At point A in the program, what names are in scope? b. At point A in the program, what variables are live? c. At point B in the program, what names are in scope? d. At point B in the program, what variables are live?Each of the following definitions and program segments has errors. Locate as many as you can and correct the errors. a) void showValues (int nums) { for (int i = 0; i<8; i++) cout<public static void main(String [] args) { // Step 2: Construct a Day object representing today // and assign it to a variable called aDay // Step 3: Construct a Day object representing the day for our Exam1 on March 1, 2022, and assign it to a variable called examOne // // // Step 4: Declare three integer variables called year, month and day with initial values of 2022, 4, 12. // // 4 // Step 5: Construct a Day object using the three variables and assign it to a variable called examTwo 6. :7 28 29 // // Step 6: Display the three days on separate lines without any messages 30 31 // 32 33 // Step 7: Display the number of days as a positive integer between the two exams with a message 34 35 // 36 // "Number of days between the two exams: " 37 38 39 // Step 8: Update aDay to the day two days later 40 41 // Step 9: Print the year, month and day of aDay, one value per line without any messages 42 43 // 44 45 } 46 47#include using namespace std; const int y = 1; int main () { int static y = 2; int i = 3, j = 4, m = 5, n = 6; %3D int a = [] (int x, int i = 1) { return x * i; } (y, 3) ; %3D int b = [=] (int x) { return [=] (int b) { return b + j; } (x) % 7; } (a); int c = [=] (int x) mutable ->int { m = 6; return [6] (int j) mutable { y = a * b; return y / j; } (x) -m; } (b) ; cout << a << endl; cout << b << endl; cout << c << endl; cout << m << endl; cout << y < endl; return 0; This program outputs 5 lines. What are they? Please explain your work and your answer.#include using namespace std; class fraction{ float d,s; public: fraction() { d=0; s=1; fraction(int a, int b) { d=%3; s=b3; } void print() { cout<Void Do1 (int: &, a. int &b) { a = 5; a = a + b; b = a + 2; } Int main() { Int x = 10; Do1 (x,x); Cout << x << endl; } The output of this program isIn C++ QUESTION 14 class rectangleType { public: void setLengthWidth(double x, double y); //Sets the length = x; width = y; void print() const; //Output length and width double area(); //Calculate and return the area of the rectangle (length*width) double perimeter(); //Calculate and return the perimeter (length of outside boundary of the rectangle) private: double length; double width; }; Write the function definition for the function perimeterBIRZEIT UNIVERSITY COMP242 – Project# 2 Buying/Selling Shares of Stocks Buying and selling shares of stocks of listed companies is a typical task to do among investors. Of course, this would result in a capital gain (or loss) when the shares are sold. This is computed as the difference between the shares' selling price and the price was originally paid to buy it. When an investor has a single share of stock, the process is easy. However, when (s)he sells multiple shares of stocks, bought over a period of time and possibly with different prices, the first step is to identify which shares of stocks are to be sold. There are two accounting principles (protocols) that are followed depends on the market of stocks: the shares bought last to be sold first, and the other is to sell the shares that stayed the longest. You are required to implement a program to calculate the possible capital gain/loss using these two protocols. This would facilitate the process for investors to know which market…#include<stdio.h>#include<stdlib.h> int cent50=0;int cent20=0;int cent10=0;int cent05=0; void calculatechange(int* change){if(*change>0){if(*change>=50){*change-=50;cent50++;}else if(*change>=20){*change-=20;cent20++;}else if(*change>=10){*change-=10;cent10++;}else if(*change>=05){*change-=05;cent05++;}calculatechange(change);}}void printchange(){if(cent50)printf("\n50cents:%d coins",cent50);if(cent20)printf("\n20cents:%d coins",cent20);if(cent10)printf("\n10cents:%d coins",cent10);if(cent05)printf("\n05cents:%d coins",cent05);cent50=0;cent20=0;cent10=0;cent05=0;}void takechange(int* change){scanf("%d",change);getchar();}int main(){int change=0;int firstinput=0;while(1){if(!firstinput){printf("\nEnter the amount:");firstinput++;}else{printf("\n\nEnter the amount to continue or Enter -1 to…SEE MORE QUESTIONSRecommended textbooks for youC++ Programming: From Problem Analysis to Program…Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningEBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENTC++ Programming: From Problem Analysis to Program…Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningEBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT