Complete the class Problem 1, the program does the following: Prompt the user to enter an integer n.
Q: 1. Find the incorrect/missing parts and correct them. Program Answers #include int main(void); int…
A: The given code has some errors and some missing parts. I have modified the code accordingly.
Q: In the following program, shown below, the print result is #include void main() (int a-1,b; b=++a;…
A: In this problem we need to design the code in the c++ and need to run and check for the output.…
Q: What are the memory sections for variables in the following code: int *x=new int;…
A: The question is: finding the memory sections for variables in the given code.
Q: Suppose you are given the following information: Integer:first_day. This is the day on Jan 1…
A: #include <bits/stdc++.h>using namespace std; int main(int argc,char *argv[]) { int…
Q: Write a program to ask user to enter number of codes. Assign a letter for each code and possibility.…
A: The code is given below
Q: The result of the following program is #include void main() { int n; float m=7; n=m%2;…
A:
Q: void functionThree(int number) { time = 0; %3D for ( int i =0; i< number; i++) for( int j=0; j< i *…
A:
Q: The following recursive method has been created. This method accepts two integer parameters called a…
A: Step 1 The answer is given in the below step
Q: Part3: Write a method to compute the following series: Write a test program that displays the…
A: Given:
Q: Why the code below may generate a error? for (int i 0; i<= 10; i++) cout << i+; cout << i- +;
A: The given code: for( int i=0; i<=10; i++) cout<<i+-;cout<<i-+; In the above cout…
Q: Q2)Write a program that asks the user to type two numbers x, y and an arithmetic symbol s. Depending…
A: The Java code is given below:
Q: Problem specification: There is a grid of NXN squares. We can easily determines how many different…
A: Below is the required code in java language. PROGRAM: // Import necessary namespaces to get the…
Q: (b) Rewrite the program below to use compound assignments, submit the code and the output for the…
A: 3. Using compound operators += compound addition assignment operator-= compound subtraction…
Q: What is the value of num3 after the following code is executed: int num1; int num2; int num3; num1 =…
A: value of num1 is 15.
Q: (a) Suppose Circle is a class. Now draw the memory allocation of the following four statements.…
A: Here, a Circle object with the name c1 is declared. Then, c1 is transferred to another circle (c2)…
Q: (b) Given a and b are int variables and c is a double variable. The initial value for a, b, and c…
A: Postfix Operator: value of the variable is first used the expression and its incremented by 1. Since…
Q: The type of error in the following prog #include void main() {int m,n; for(m-1;m<4;++m)…
A: Lets see the solution.
Q: 1.Using pseudocode, a method that will add two numbers, and return the sum to the calling function.…
A: The, code has given below:
Q: Find the error in the following code and explain: #include int main(void) int n 9, div = 0; div n/%;…
A: GIVEN:
Q: What
A: Program code: //class definitionclass Test{ //main method public static void main(String[] args)…
Q: The following code is syntactically correct meaning it will compile. for (int k=0; k<10; k++) {…
A: Answer: False EXPLANATION: Error in following code:
Q: The following piece of code calculates base to the power of n (base"), please choose the correct…
A: Program public class basen { static void basen(int base,int n) { int result=1;…
Q: ublic static int methodA(int n) { int result 0; for(int i = 0; i ®; k--){ result += k; } return…
A: Time complexity defines the running time of the given program. OR , it defines the worst case…
Q: Having trouble with this c++ homework question. void a(int n) { if(n<1) { cout <<…
A: Having trouble with this c++ homework question. void a(int n) { if(n<1) { cout…
Q: (THIS IS THE GIVEN CODE) int main(int argc, char *argv[]) { int first_day = atoi(argv[1]);…
A: I have implemented the given requirements as mentioned above in C++. Proper validations are in…
Q: What is the value of name after the following steps are executed? float name, x=20.5; float *a = &x;…
A: Here the value of x=20.5 Now *a = &x this means that *a will have the value present at the…
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: 2. Write a program with a user interface which allows the user to enter 2 integers. It should then…
A: Program to perform addition, subtraction, multiplication and division on two input numbers in Python
Q: Add the correct data type for the following variables: myNum 9; myDoubleNum = 8.99; myLetter 'A';
A: Given: 5 variables are given with their variable name and value. Requirement: Write the correct data…
Q: Problem specification: There is a grid of NXN squares. We can easily determines how many different…
A: Given:-
Q: b) void func (int n) { for sh (int i = 0; i < n; i = i + 10) { for (int j = 0; j < i; ++j)…
A: b. Worst case running time: void func(int n) { for (int i = 0; i < n; i = i + 10) { for (int j =…
Q: Complete the following sentences by filling the right word The purpose of (int) in the statement:…
A: Answer: The purpose of (int) in the statement: int x = (int)(Math.log(16)); is toint x = (int)…
Q: 3. a) What is the output when you invoke the methodA with 45. public static int methodA (long n) {…
A: The solution of the above question are given below:
Q: Variables of type single occupy half the memory of variables of type double, but they have lower…
A: Variables of type single occupy half the memory of variables of type double, but they have lower…
Q: void functionOne(int number) { if (number < 10) time++; else { for (int i= 0; i< number; i++)…
A: Ans 1: The big oh notation of the first given function is O(n). As per the given function the for…
Q: What does the following program segment do? for ( int i = 1; i <= 5; i++ ) { e. for ( int j = 1; j…
A: The inner loop is displaying *4 times and j will be executed 3 times so it will be 3 rows and 4…
Q: Find the error in the following code and explain how to fix it: #include int main(void) int *ptr3;…
A: In this given code you are trying to print value of ptr which is storing the value of m. so you…
Q: Java Write a program that calculates the weight of number that should be taken from number. For…
A: Requirements :- Java Write a program that calculates the weight of number that should be taken from…
Q: The special case return value that will terminate the following code i
A: The special case return value that will terminate the following code is ____________________. int…
Q: Q1 \ write program in C# language to find the average of student marks in three subjects…
A: First, we will input the marks in 3 subjects. Then we will call the function avg_no. This function…
Q: (a) Write a main funetion, integer return, that accepts no arguments. (b) Write code that displays…
A: /*C program with main function that return integer and accepts no argument and display text…
Q: Identify the actual parameters from the code snippets below. float final (int a) return a + 10; }…
A: In programming language, Actual Parameters: Actual parameters are values that are passed to a…
Q: Write a program that asks the user to input the following data for n employees: - • Basic Salary •…
A: (1)First we read the number of employees (2)Loop for each employee (3) Read the salary (4)Read the…
Q: The following program have syntax errors. Correct them. On each successive line, assume that any…
A: //Syntax errors in given codepublic class Exercise25{static final char = STAR = '*' //two…
Q: Find the value of A, B #include void main ( ) { int A,B=5; A=B++; cout<<A<<"\n"<<B<<"\n"; }
A: The given program is C++. Asked to find the output of the program. I had run this program on online…
Q: int this as soon as Code design.
A: I have written HTML Code below:
Q: nsider: lic static void printAll(int[] a) { N = a.length;
A:
Q: a. Prompt the user to type a word on console and save the input into variable b. Implement recursive…
A: As per the given problem, we have to do the following : 1. Get a word as input from user. 2. Check…
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 3 images
- Fibonacci A fibonacci sequence is a series of numbers in which each number is the sum of the two preceding numbers. For example: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, and so on… For this, you will implement a class that takes a positive integer (n) and returns the number in the nth position in the sequence. Examples When n is 1, the returned value will be 0. When n is 4, the returned value will be 2. When n is 9, the returned value will be 21. come up with the formula and base cases Implementation Create a class Fibonacci with a public static method getValue. Create a Main class to test and run your Fibonacci class.Exercises: PolymorphismProblem 1. VehiclesWrite a program that models 2 vehicles (Car and Truck) and will be able to simulate driving and refueling them inthe summer. Car and truck both have fuel quantity, fuel consumption in liters per km and can be driven givendistance and refueled with given liters. But in the summer both vehicles use air conditioner and their fuelconsumption per km is increased by 0.9 liters for the car and with 1.6 liters for the truck. Also the truck has a tinyhole in his tank and when it gets refueled it gets only 95% of given fuel. The car has no problems when refueling andadds all given fuel to its tank. If vehicle cannot travel given distance its fuel does not change.Input On the first line - information about the car in format {Car {fuel quantity} {liters per km}} On the second line – info about the truck in format {Truck {fuel quantity} {liters per km}} On third line - number of commands N that will be given on the next N lines On the next N lines –…InstructionsDefine an enumeration type triangleType that has the values scalene, isosceles, equilateral, and noTriangle.Write a function triangleShape that takes as parameters three numbers, each of which represents the length of a side of the triangle. The function should return the shape of the triangle. (Note: In a triangle, the sum of the lengths of any two sides is greater than the length of the third side.)Write a program that prompts the user to input the length of the sides of a triangle and outputs the shape of the triangle.
- Quadratic equations The form of a quadratic equation is ax2 + bx + c = 0. Write a program that solves a quadratic equation in all cases, including when both roots are complex numbers. Remember that the solutions are x = (-b + sqrt(b2 -4ac))/2a and (-b - sqrt(b2 -4ac))/2a For this you will need to set up the following classes: Complex: Encapsulates a complex number. ComplexPair: Encapsulates a pair of complex numbers. Quadratic: Encapsulates a quadratic equation. – Assume the coefficients are all of type int for this example. SolveEquation: Contains the main method. (I give this to you it is shown below) Along with the usual constructors, accessors and mutators you will need the following additional methods: In the Complex class a method called isReal to determine whether a complex object is real or not returning a boolean value. In the ComplexPair class a method bothIdentical that determines if both complex numbers are identical, returning a boolean value. In the…JAVA PROGRAM ASAP *********** THIS PROGRAM MUST WORK IN HYPERGRADE AND PASS ALL THE TEST CASES. Please create a program BECAUSE IT IS. MY HOMEWORK ASSIGNMENT with the following parts which are down below: The left index is inclusive and the right index is exclusive. 1. public static void bubbleSort(int[] array, int left, int right) { // your code here } 2. public static void insertionSort(int[] array, int left, int right) { // your code here } 3. public static void selectionSort(int[] array, int left, int right) { // your code here } Test Case 1 Please enter a space separated list of numbers to sort or type QUIT to exit:\n4 3 2 1ENTERSorting first half of the array using Bubble Sort algorithm:\n3 4 2 1\nSorting second half of the array using Bubble Sort algorithm:\n4 3 1 2\nSorting the array using Bubble Sort algorithm:\n1 2 3 4\nSorting first half of the array using Insertion Sort algorithm:\n3 4 2 1\nSorting second half of the array using Insertion…mport java.util.Scanner; public class ParkingCharges { // function to calculate the basic charge using the asked hours static double getBasicCharge(int hours) { if (hours >= 7 && hours <= 8) return 5.50; else if (hours >= 5 && hours <= 6) return 4.50; else if (hours >= 2 && hours <= 4) return 4.00; return 3.00; } // function to return the amount to subtract based on local living and OAP static double getDiscount(String isLocal, String isOAP) { if (isOAP.equals("Yes") && isLocal.equals("Yes")) return 2.0 + 1.0; else if (isOAP.equals("Yes")) return 2.0; else if (isLocal.equals("Yes")) return 1.0; return 0; } public static void main(String[] args) { // create a new Scanner object Scanner sc = new Scanner(System.in); // prompt the user to ask if they are disabled…
- Write a Rational class. Recall a rational number is a rational number, composed of two integers with division indicated. The division is not carried out, it is only indicated, as in 1/2, 2/3, 15/32. You should represent rational numbers using two int values, numerator and denominator. #include <iostream> #include <string> #include <stdlib.h> using namespace std; class rational { public: /* default constructor set the rational number to 0, (i.e., numerator is 0, denominator is 1) */ rational(); /* Set the invoking object's value from user input */ void input(); /* Display invoking object's value in the standard output, in the form of numerator/denominator */ void output() const; //return the invoking object's numerator int get_numerator() const; //return the invoking object's denominator int get_denominator() const; // Set invoking object to be the sum of op1 and op2 void Add(const rational& op1, const rational& op2); // Set the invoking…Create a class named RecusiveMethod having a recursive method. The recursive method accepts an integer argument and displays all even numbers from 1 up to the number passed as an argument. For example, if 25 is passed as an argument, the method will display 2, 4, 6, 8, 10, 12, 14, ……24. Demonstrate the method.Fix the Java code below: Make sure to have the right code indentation Make sure the "Main" function run the right way Code: import java.util.*; class RemoveDuplicates { public static void Main(String[] args) { int a[]={1,3,5,2,3,5,3,3,5,7,9,3}; System.out.print("Before Sorting:"); for (int i=0; i<a.length; i++ ) { System.out.print(a[i]+"\t"); } System.out.print ("\nAfter Sorting:"); //sorting the elements for(int i=0;i<a.length;i++) { for(int j=i;j<a.length;j++) { if(a[i]>a[j]) { int temp=a[i]; a[i]=a[j]; a[j]=temp; } } } //After sorting for(int i=0;i<a.length;i++) { System.out.print(a[i]+"\t"); } System.out.print("\nAfter removing duplicates:"); System.out.print("\n Here are the distinct numbers:"); int b=0;…
- JAVA PROGRAMMING Write two java files for this assignment: Circle.java, and Main.java. The Circle.java file will create an actual class. The Circle class: MEMBER VARIABLE double radius double x double y Eight methods: Six of the methods are simple: getter’s and setter’s for x, y, and radius. There should also be a getArea method that returns the area (derived from the radius) A doesOverlap method. This method should accept a Circle as an argument, and return true if this circle overlaps the circle that the method was invoked on. [Note: two circles overlap if the sum of their radius' is greater than or equal to the distance between their centers.] void setX(double value) double getX() void setY(double value) double getY() void setRadius(double value) double getRadius() double getArea() boolean doesOverlap(Circle otherCircle) second class will be the typical replit Main class, with its static main method .It should contain code that tests the Circle class. submit code that…Using the dialog boxes in the JOptionPane class, write a program that calculates and prints themonthly paycheck for an employee. Use the class name “LastnameClasscodeFinal1”. The netpay is calculated after taking the following deductions:a) Federal Income Tax: 15%b) State Tax: 3.5%c) Social Security Tax: 5.75%d) Medicare/Medicaid Tax: 2.75%e) Pension Plan” 5%f) Health Insurance: $ 75.00Your program should prompt the user to input the gross amount and the employee name. Formatthe output to have two decimal places. A sample output follows:Using the dialog boxes in the JOptionPane class, write a program that calculates and prints themonthly paycheck for an employee. Use the class name “LastnameClasscodeFinal1”. The netpay is calculated after taking the following deductions:a) Federal Income Tax: 15%b) State Tax: 3.5%c) Social Security Tax: 5.75%d) Medicare/Medicaid Tax: 2.75%e) Pension Plan” 5%f) Health Insurance: $ 75.00Your program should prompt the user to input the gross amount and the employee name. Formatthe output to have two decimal places. A sample output follows: Juan Dela CruzGross Amount: $ 3575.00Federal Tax: $ 536.25State Tax: $ 125.13Social Security Tax: $ 205.56Medicare/Medicaid Tax: $ 98.31Pension Plan: $ 178.75Health Insurance: $ 75.00Net Pay: $ 2356.00