| 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}...
Consider the following code in c++ template <class T> int F1(T* A, int n) { int v = 1; for (int i = 0; i < n - 1; i++) if (A[i] != A[i + 1]) v++; return v; } int main() { string X[10] = { "aaa","bbb","bbb","bbb","bbb" }; int a = F1(X, 5); return 0; } what is the value of the variable a?
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...
can some help me why it is erroring. I cannot find the mistake in the code. It is to implment a circular double linked list. please and thank you ////////////////////////////////////////////////////////////////////////// HEADER FILE //////////////////////////////////////////////////////////////////////// #pragma once #include <cstdlib> template <typename T> class Node { public: T val; Node<T> *next; Node(T v) { val = v; next = NULL; } }; /////////////////////////////////////////////////////////////////////////////////// STACK.CPP FILE /////////////////////////////////////////////////////////////////////////////////// #include "Stack.h" template <typename T> class Stack {...
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...