else if (line.Contains(",")) | |
{ | |
string code = line; | |
string val = ""; | |
for (int i = 9; i < code.Length; i++) | |
val += code[i]; | |
int v; | |
if (val.Contains("-")) | |
v = Convert.ToInt32(val) * (-1); | |
else | |
v = Convert.ToInt32(val); | |
String baze = code.Substring(5, 3); | |
objFile.WriteLine(String.Format("{0:X}", lc) + "\t" + getBinary(baze, v, !code.Contains("-"))); | |
lc++; how to translate this to Java getBinary is a function implemented in my project |
else if(line.contains(",")) //in java contains() is used
instead of Contains()
{
String code=line;
String val="";
for(int i=9;i<code.length();i++) //in java length() is used to
return the length
{
val+=code[i];
}
int v;
if(val.contains("-"))
{
v=((int)val) * (-1); //does same as Convert.ToInt32() in
c++
}
else
{
v=((int)val);
}
String baze=code.substring(5,3); //in java substring() is used to
get a substring
System.out.println(String.Format("{0:X}", lc) + "\t" +
getBinary(baze, v, !code.contains("-")));
}
else if (line.Contains(",")) { string code = line; string val = ""; for (int i = 9; i <...
[C#] I need to convert this if/else statements into Switch I have the code for the if/else but now need to turn it into a switch. The Console.WriteLine and all that is fine. I just need to convert the if/else. int x1, x2, y1, y2; Console.WriteLine("What is smallest value of x:"); x1 = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("What is largest value of x:"); x2 = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("What is smallest value of y:"); y1 = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("What is largest value of y:"); y2 =...
string hex = String.Format("{0:X}", dec); this line is in c# how to translate this line to c++ or java
I need to update this code: #include <iostream> #include <string> #include <cctype> using namespace std; int main() { string s; cout<< "Enter a string" <<endl; getline (cin,s); cout<< s <<endl; int vowels=0,consonants=0,digits=0,specialChar=0; for (int i=0; i<s.length(); i++) { char ch=s[i]; if (isalpha(s[i])!= 0){ s[i]= toupper(s[i]); if (ch == 'a'|| ch == 'e'|| ch == 'i'|| ch == 'o' || ch == 'u') vowels++; else consonants++; } else if (isdigit(s[i])!= 0) digits++; else specialChar++; } cout<<"Vowels="<<vowels<<endl; cout<<"Consonants="<<consonants<<endl; cout<<"Digits="<<digits<<endl; cout<<"Special Characters="<<specialChar<<endl;...
A function, fun_a, has the following overall structure: int fun_a(unsigned x) I int val 0 while retura Th e Gcc Ccompiler generates the following assembly code: %ebp+8 novi movl test1 x at 8 (%ebp), %eax 80, %eax %edx, %eax 2 L.7 5 .L10 %eax, %edx し10 xor1 %eax shr1 Shift right by1 ne 9.L7 10 andl $1, %eax Reverse engineer the operation of this code and then do the following: A. Use the assembly-code version to fill in the missing...
I am unsure how to add the following methods onto this code?? please help - rowValuesIncrease(int[][] t) A method that returns true if from left to right in any row, the integers are increasing, otherwise false. - columnValuesIncrease(int[][] t) A method that returns true if from top to bottom in any column, the integers are increasing, otherwise false. - isSetOf1toN(int[][] t) A method that returns true if the set of integers used is {1, 2, . . . , n}...
How do I set up my read function? here's my code so far: int read_sudoku_board(const char file_name[], int board[9][9]) { FILE * fp = fopen("sudoku.txt", "r"); int a,i,j,c; int count = 0; for(i = 0; i < a; i++){ for(j = 0;j < 9;j++){ c = fgetc(fp); if(c == '-'){ board[i][j] = 0; } else if(c >= 1 && c <= 9) printf(" %d"); else return -2; } count++; } if(count != a-1) return -1; else return 0; }12 Read...
please evaluate the following code. this is JAVA a. class Car { public int i = 3; public Car(int i) { this.i = i; } } ... Car x = new Car(7), y = new Car(5); x = y; y.i = 9; System.out.println(x.i); b. class Driver { public static void main(String[] args) { int[] x = {5, 2, 3, 6, 5}; int n = x.length; for (int j = n-2; j > 0; j--) x[j] = x[j-1]; for (int j...
Line number 9 contains the code line that declares the result array ( asked in another question of this exam). On Line number 11 where col_ contains the correct statement ( asked in another question of this exam) Question: Write the codeline (single line) to compute the matrix multiplication of "frstMatrix" and "scndMatrix". For this question you will write a code line for line number 17 1 package ok4; 2 //This java program multiplies two matrices 3 //represented with two...
1. What is the output? System.out.print(3 + 3 * 3); a. 18 b. 12 c. 9 d. 0 e. 10 2. What is output by the code below? System.out.print("\\dog\\cat"); a. dog b. dogcat c. \\dog\\cat d. \dog\cat e. catdog\\\\ 3. What is returned by the call getIt(9) ? public static int getIt(int num){ int ans = 0; if( num >=2 ) { if( num >= 7) ans += 2; else ans += 3; } ans += 4; return ans; }...