Predict the output of the program. class A { public int i; }; void main() { A x; A y=x; x.i=10; y.i=20; y.i++; y.i=20; cout&l;<tx.i; } i) 10 ii) 20 iii) 21 iv) 0
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: There
A: Here is the detailed and simplified answer to the above listed problem statement:
Q: plain this java code
A: Descriptions: 1- Please check the following updated code with comments line by line. 2- There are…
Q: using System;public static class Lab3_2{public static void Main(){// declare the variables and…
A: Remove the syntax error from the given C# code and run it for input weight 2. About the given code:…
Q: error
A: the following code has a syntax error Figure out the error and correct it ? class access…
Q: What is the primary purpose of a router in the OSI model, and which layer of the model does it…
A: The primary purpose of a router in the OSI (Open Systems Interconnection) model is to enable the…
Q: n the box provided below, or to the right of, each of the small programs on this and the next page,…
A: Output will be - 3_6_8 -2_6_29
Q: 1. Add a field to the Hexagon.java class called side. It should be a double. 2. Write a no arguments…
A: Constructor is called when a instance of the class is created. It is used to initialize the object.…
Q: 1. What is the output of the following program? Explain why? public class Boy{ int age = 10; }…
A: //lets trace the code for outputpublic class Boy{ int age=10;//data member}public class School{…
Q: c++, print the output
A: Since the question only mentioned the output, I'm providing the output for given code: y: 16x : 81x:…
Q: include void fun1(int num, ...); void fun2(int num, ...); int main() { fun1(1, "Apple", "Boys",…
A: Explanation: The code defines two functions, fun1 and fun2, which have variable arguments. In the…
Q: For the “Class C”: There is 2 ways for fixing this functions. Firstly fix the “yaz” and “yaz2” error…
A: The given code is in C++ language with inheritance where 1) Class A is parent class 2) Class B…
Q: Translate the following C++ code to MIPS assembly language in Mars with
A: Writing MIPS assembly code is a common task for those who are working in computer science or related…
Q: What is the output of the code on the right?
A: Java is an object oriented programming language.
Q: // this solves the area of a circle #include #define PI3.1415927 double Area(double r) double…
A: We need to debug the given c++ code and correct it.
Q: Write a java program using parameterised constructor to display student details such as student…
A: Sample Response: //Java program to display the details of a student by using the parametrized…
Q: In C++ QUESTION 14 class rectangleType { public: void setLengthWidth(double x, double y);…
A: In order to write and test the function definition of perimeter we also need to write the function…
Q: #include #include void fun1(int num, ...); void fun2(int num, ...); int main() { fun1(1, "Apple",…
A: Include the necessary header files: stdio.h for input/output operations and stdarg.h for handling…
Q: a) b) C) d) CO 1 123 2 4 5 6 7 8 9 10 11 12 20 19 TELE 345 13 #include #include int main(){ 14 15…
A:
Q: Modify Activity 2 to create an array of 3 students. Use a loop to fill the array with information,…
A: Declare an integer constant numStudents as 3. Declare an array of Student objects named students…
Q: roduct sold by the juice machine. 2. Let the customer make the selection. 3. Show the customer the…
A: Q. Fruit Juice MachineIn this programming example, there are one function available which is main()…
Q: } class ChoiceQuestion public Question { public: ChoiceQuestion(); void set_text(string new_text);…
A: In object-oriented programming (OOP), the idea of function overriding is used when a subclass offers…
Q: The bank doubles the customer’s balance every year until the customer’s balance reaches one million.
A: The below program calculates the number of years required to reach specific balances in a bank…
Q: C++ Programing ATTRIBUTES NOTE: The important method has been given to you. userld:int //generates…
A: A class is the basic unit of object oriented design. An instance of a class is called an object. A…
Q: * iii. This program calculates the driving skill and points of two players in a driving game. *…
A: Total code is in the final step from start to end. This method is use to take the input we can use…
Q: 4. Create the following getter methods a. Getter method for firstname (use ? getFirstname( ) ). b.…
A: The object-oriented programming language provides encapsulation to hide the members of the class.…
Q: An anagram is a word that has been rearranged from another word, check to see if the second word is…
A: output
Q: public static void main(String [] args) { // Step 2: Construct a Day object representing today and…
A: As per the given problem, we need to perform steps 2 to 9 in Java thereby completing the java…
Q: Computer Science c++ help comment code please. Complex has multiple parameters to overload i think.…
A: The given class Complex has 2 private attributes real and complex The class has default constructor,…
Q: The following declaration, program, and program segment has errors. Locate as many as you can. class…
A: This program consists of seven errors. The following statements contain errors: The first error…
Q: complete and create magical square #include using namespace std; class Vec { public: Vec() { }…
A: #include <iostream> using namespace std; class Vec { public: Vec() { } int size() { return…
Q: Write a test program that would take at least 3 combinations of amounts entered and choices of…
A:
Q: Add screenshots of outputs as well Execute the following example and write a comment after each…
A: The code after adding the comments is as follows: #include<iostream> #include<string>…
Q: C programming #include int main() { int i, j, n ; printf("height? ") ; scanf("%2d", &n) ; for (i =…
A: Answer: program 1:- #include <stdio.h> int main() { int i, j, n ; printf("height? ") ;…
Q: Identify errors if there is any & after identifying rewrite the code: public class Employce {…
A: Error Free Textual Code :- //The type Employee must be an abstract class to define a abstract…
Q: starsPrint ♡ Language/Type: Java expressions % What output is produced by each of the following code…
A: Solution: Given, //A for(int i=0;i<5;i++){ for(int j = 0; j<18; j++) {…
Q: When we wish to add new methods to the superclass that do not necessarily apply to all subclasses.…
A: Introduction: The functionality of instance variables is defined in the following statement. As an…
Q: Write a class named CourseGrades. The class should have a member named grades that is an array of…
A: import java.text.DecimalFormat; /** * class that holds all grade objects for course */public class…
Q: Online Food Ordering Application User Log in Meals (Breakfast/Lunch/Dinner) No Log Out Do you want…
A: I give the code in Java along with code and output screenshot
Q: Q1. /* date.h */ #ifndef DATE H #define DATE_H__ class Date { public: Date (int=1, int=1, int=2000);…
A: Date class is a c++ custom date that contains the three private data members to store day, month and…
Q: Hospital Management Project "Simple Scenario We want to develop a comprehensive software product for…
A: A state diagram, sometimes characterized as a state machine diagram or a state chart diagram, is a…
Q: Determine the output of the following program: int main() int x=3,y=4,z=6; int *p1,*p2,*p3; p1=&x;…
A: Requirement- Determine Output of Following program Solution- Pointer variables store the address of…
Q: Vrite a C+ program that prompts the user to enter the earthquake magnitude and utputs its class. We…
A: so, here we have to write a c++ Program that prompts the user to enter the earthquake magnitude and…
Q: Vrite a class of objects named Date that remembers information about a month and day. Ignor leap…
A: public class Dat private int month;private int day;public Date(int month, int day)public int…
Q: JAVA CLASS AND OBJECT Write a program that creates a "Car" as an object, and displays the Year and…
A: Given: JAVA CLASS AND OBJECT Write a program that creates a "Car" as an object, and displays the…
Predict the output of the
class A
{
public int i;
};
void main()
{
A x;
A y=x;
x.i=10;
y.i=20;
y.i++;
y.i=20;
cout&l;<tx.i;
}
i) 10
ii) 20
iii) 21
iv) 0
Trending now
This is a popular solution!
Step by step
Solved in 2 steps
- Charge Account Validation Using Java programming Create a class with a method that accepts a charge account number as its argument. The method should determine whether the number is valid by comparing it to the following list of valid charge account numbers:5658845 4520125 7895122 8777541 8451277 13028508080152 4562555 5552012 5050552 7825877 12502551005231 6545231 3852085 7576651 7881200 4581002These numbers should be stored in an array. Use a sequential search to locate the number passed as an argument. If the number is in the array, the method should return true, indicating the number is valid. If the number is not in the array, the method should return false, indicating the number is invalid.Write a program that tests the class by asking the user to enter a charge account number. The program should display a message indicating whether the number is valid or invalid.complete the missing code. public class Exercise09_04Extra { public static void main(String[] args) { SimpleTime time = new SimpleTime(); time.hour = 2; time.minute = 3; time.second = 4; System.out.println("Hour: " + time.hour + " Minute: " + time.minute + " Second: " + time.second); } } class SimpleTime { // Complete the code to declare the data fields hour, // minute, and second of the int type }using System;public static class Lab3_2{public static void Main(){// declare the variables and constantsconst double FLAT = 1.25;double weight;double cost, pricePerKg = 0;// Input the weightConsole.Write("Enter a positive weight of the package => ");weight = Convert.ToDouble(Console.ReadLine());// Determine the cost per kilogramif (weight <= 0)Console.WriteLine("*** Invalid weight");else if (weight < 1)pricePerKg = 0.25;else if (weight <= 3.5)pricePerKg = 0.5;else (weight > 3.5)pricePerKg = 1.0;// Compute the cost to send the packageif (weight > 0)cost = weight * pricePerKg + FLAT;elsecost = 0;// Output the resultsConsole.WriteLine("The cost to send the package is {0:C}",cost);Console.ReadLine();}} Remove the error from the given program and run it for input weight 2.5.
- public class StairViewer public static void main(String(] args) // Step 2: Create a rectangle and draw it as the // top step of the stair // location: (20, 10) // size: (20, 20) 18 // Step 3: Create a rectangle and draw it as the 19 // middle step of the stair 20 // location: below the top step, aligned on left // size: (40, 20) 21 22 23 24 // Step 4: Create a rectangle and draw it as the 25 // bottom step of the stair 26 // location: below the middle step, aligned on left // size: (60, 20) 27 28 29 30 } 31 32C# PROGRAM THE AVERAGE MUST HAVE DECIMAL2. Create one user object that invokes the default constructor.
- void fun(int i) { do { if (i % 2 != 0) cout =1); cout << endl; } int main() { int i = 1; while (i <= 8) { fun(i); it; } cout <Collapse Problem #2 Complete the class Problem2, the program does the following: • The program prompts the user to enter an integer. • The program continues to prompt the user for more integers as long as the sum of all values entered is between 1 and 50. • If the sum of all values entered is NOT between 1 and 50, Java the program stops taking integers, then display the value of sum. Here are two sample outputs, your output should look exactly the same as follows: Enter an integer: 23 Enter an integer: 1 I Enter an integer: -2 Enter an integer: 19 Enter an integer: -25 Enter an integer: 4 Enter an integer: 9 Enter an integer: -20 Enter an integer: -5 Enter an integer: -12 AK -8 lacBook Aira) Test two of the methods in this code.Flight assignment runs but there is no imput values for the user to interact when running the program. Kindly fix this issue.import java.util.*; class Flight { String airlineCode; int flightNumber; char type; // D for domestic, I for international String departureAirportCode; String departureGate; char departureDay; int departureTime; String arrivalAirportCode; String arrivalGate; char arrivalDay; int arrivalTime; char status; // S for scheduled, A for arrived, D for departed public Flight(String airlineCode, int flightNumber, char type, String departureAirportCode, String departureGate, char departureDay, int departureTime, String arrivalAirportCode, String arrivalGate, char arrivalDay, int arrivalTime) { this.airlineCode = airlineCode; this.flightNumber = flightNumber; this.type = type; this.departureAirportCode = departureAirportCode; this.departureGate = departureGate;…tranlate source program in the picture into quadruples tranlate source program in the picture into quadruples tranlate source program in the picture into quadruplesRemaining Time: 31 minutes, 51 seconds. ¥ Question Completion Status: What is the error in the below code? Provide your explanation. #include using namespace std; class parent{ private: int i, j; public: parent (int i, int j) class child: public parent { public void show(){ cout<<" i = "<SEE MORE QUESTIONSRecommended textbooks for youDatabase System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSONC How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag…Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill EducationDatabase System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSONC How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag…Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education