While solving the question, i have written the whole pseudocode along the some explanation of the code in comment fashion to help you understand the program. Consider the output written in the rectangular box as on a single line separated by single space.
Given the following pseudocode: Class Coordinate Private Real _x Private Real y Public Module set_x(Real value)...
What will the following pseudocode program display? Module main( ) Declare Integer x = 1 Declare Real y = 3.4 Display x, " ", y Call changeUs(x, y) Display x, " ", y End Module Module changeUs(Integer a, Real b) { Set a = 0 Set b = 0 Display a, " ", b }
Look at this partial class definition, and then answer questions a - b below: Class Book Private String title Private String author Private String publisher Private Integer copiesSold End Class Write a constructor for this class. The constructor should accept an argument for each of the fields. Write accessor and mutator methods for each field. Look at the following pseudocode class definitions: Class Plant Public Module message() Display "I'm a plant." End Module...
What is wrong with the following code: class Point { private : int x, y; public : Point (int u, int v) : x(u), y(v) {} int getX () { return x; } int getY () { return y; } void setX (int newX ) const { x = newX ; } }; int main () { Point p(5, 3); p.setX (9001) ; cout << p. getX () << ’ ’ << p. getY (); return 0; }
public class Point f private int x; private int y; public Point(int x, int y) this.x X; this.y y; public int getX() return x; public int getY() return Y: public double distance (Point other) double dx this.x-other.x; double dy this.y-other.y double dist Math.sqrt(dx dx + dy dy); return dist;
Create a basic math quiz program that creates a set of 10 randomly generated math questions for the following operations:AdditionSubtractionMultiplicationDivisionModuloExponentThe following source files are already complete and CANNOT be changed:MathQuiz.java (contains the main() method)OperationType.java (defines an enumeration for valid math operations and related functionality)The following source files are incomplete and need to be coded to meet the indicated requirements:MathQuestionable.javaA Random object called RANDOM has already been declared and assigned, and you must not change this assignment in any way.Declare and assign an interface integer called MAX_SMALL and assign it the...
Create a basic math quiz program that creates a set of 10 randomly generated math questions for the following operations:AdditionSubtractionMultiplicationDivisionModuloExponentThe following source files are already complete and CANNOT be changed:MathQuiz.java (contains the main() method)OperationType.java (defines an enumeration for valid math operations and related functionality)The following source files are incomplete and need to be coded to meet the indicated requirements:MathQuestionable.javaA Random object called RANDOM has already been declared and assigned, and you must not change this assignment in any way.Declare and assign an interface integer called MAX_SMALL and assign it the...
I am supposed to a pseudocode function named max that accepts two integer values as arguments and returns the value that is greater of the two. Use the function in a program that prompts the user to enter two integer values. The program should display the value that is greater of the two. Is everything correct and complete? //Pseudocode //This function takes two integers as parameters: x and y Begin : Max(x,y) If(x>y) then MAX=x Else MAX=y End if Return...
Question 19 Given the following class: public class Swapper ( private int x; private String y public int z; public Swapper( int a, String b, int c) ( x-a; y b; zC; public String swap() ( int temp -x; x-z z temp; return y: public String tostring() ( if (x<z) return y: else return" +x+z What would the following code output? Swapper r new Suapper( 5, "no", 10); System.out.printin( r. swap ) ): no no510 510 e 15 Question 20...
Java Inner class class Outer { private int x=10; private static int y=20 ; publics void M1( ) { int z=30; class Inner { public void M2() { Sytem.out.println(“sum: ”+ (x+y+z)); } } Inner i=new Inner(); i.M2() ; /// first call i.M2(); // second call i.M2(); // third call } // end of M1 publics static void main(String[] args) { Outer O = new...
class x { x () {} private void one () {} } public class Y extends x { Y() {} private void two () { one(); } public static void main (String[] args) { new Y().two(); } } What changes will make this code compile? a. Adding the public modifier to the declaration of class x b. Adding the protected modifier to the x() constructor c. Changing the private modifier on the declaration of the one() method to protected d....