Fix each of the following code by converting the type of the variables: a. double x = 1.5; int y = x b. String x = "1"; Int y = x; c. int x = 1; String y = x; d. double x = 1.0; String y = x;
a. double x = 1.5;
double y = x;
b. String x = "1";
String y = x;
c. int x = 1;
int y = x;
d. double x = 1.0;
double y = x;
Fix each of the following code by converting the type of the variables: a. double x...
A. What is the output of the following C++ code fragment? (all variables are of type int) int count-1; int y-100; while (count 3) y=y-1 ; count+t cout << y << endl; cout<< count <<endl What is the value of x after control leaves the following while loop? (all variables are of type int) B. int x0 while (x < 20) sum- sum+x cout << sum<< endl;
C++ class 3.2.4: If-else statement: Fix errors. Re-type the code and fix any errors. The code should convert non-positive numbers to 1. if (userNum > 0) cout << "Positive." << endl; else cout << "Not positive, converting to 1." << endl; Answer #include using namespace std; int main() { int userNum; cin >> userNum; /* Your solution goes here */ return 0; userNum = 1; cout << "Final: " << userNum << endl;
QUESTION 1 Given two double variables named x and y, which of the following statements could you use to initialize both variables to a value of 0.0? a. x | y = 0.0; b. x = y = 0.0; c. x, y = 0.0; d. none of the above 1 points QUESTION 2 When you use a range-based for loop with a vector, you a. can avoid out of bounds access b. must still use a counter variable c....
What is wrong with this Code? Fix the code errors to run correctly without error. There are two parts for one code (one question) the two parts branch off, one part has 2 sheets of code, the other has 3 sheets of code, all are small code segments for one question. Pt.1 - 2 sheets of code: public class Computer { private String make; private String type; private String modelNumber; private double cpuSpeed_GHz; private int ramSize_GB; private int hardDriveSize_GB; private...
CONSIDER THE FOLLOWING CODE: double SumString(string x, int n) { double sum = 0; for (int i = 0; i < n; i += 2) sum += x.length(); return sum; } ///////////////////////////////////////////////////////// void Question() { string a = "string"; int num = a.length(); double total = SumString(a, num); cout << "The total is: " << total << endl; } Select one: a. The total is: 14.0 b. The total is: 20.0...
Fix the following code to print whether the input is positive or negative #include <iostream> #include <string> using namespace std; void positiveOrNegative(int); // declare function int main(){ int y; int result; cin >> y; result = positiveOrNegative(y); return 0; } void positiveOrNegative(int x){ if (x>=0) cout << "Positive"; else cout << "Negative"; }
for this code fix the smtax error this is a python code for some reason my code isnt liking my returns and it bring up other symtax error so fix the following code answer should pop out the following when runned 1/ 2 + 1/ 3 + 1/ 12 = 11/12 z=' ' def math(x,y): global z if y==0 or x==0: return if y%x ==0: z=("1/"+str(int(y/x)) return if x%y ==0 z+=(int(x/y)) ...
Q15 What is the type of each of the variables? 12 Points Consider the following class: public class Overloaded { public int getValue(int i, long 1) { return 42; } public long getValue(int i) { return 21; } public String getValue(double d) { return "Hello method!"; } public char getValue (double d, int i) { return 'c'; سه مه Q15.1 2 Points Overloaded o = new Overloaded(); variable = 0.getValue(3); Enter your answer here Q15.2 2 Points Overloaded o =...
What is the output of the following code? Is there a relationship between the variables x and y? If yes, state the relationship? What is the output? int x = 19683; int i; int y = 0; for (i = x; i >= 1; i = i / 3) y++; cout << "x = " << x << ", y = " << y << endl;
FIX THE FOLLOWING JAVA CODE
public class Errors public static main(String[] args) { float sum int a = 27.5, b = 72.99; suma(a, b); System.out.println("Suma = %7:3b", sum); } //end main public static suma(float a, double b) { double suma suma = a + b; } }//end class