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: 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: 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: 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: c++, print the output
A: Since the question only mentioned the output, I'm providing the output for given code: y: 16x : 81x:…
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: 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: 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: } 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: An anagram is a word that has been rearranged from another word, check to see if the second word is…
A: output
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: 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: 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: 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: 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: 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: 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…
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
![](/static/compass_v2/shared-icons/check-mark.png)
Trending now
This is a popular solution!
Step by step
Solved in 2 steps
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
- 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.
- 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 = "<Recommended 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