CompE pod ko. Wala pod mi Java, wala pod C++ sauna.
C lang jud intawon ug 8088 compatible nga assembly language.
#3 prime numbers
#4 ExponentsCode:private boolean isPrime(int n) { if (n > 1) { for (int x = 1; x < n ; x++) { if (n % x == 0 && x != 1) { return false; } } } else { return false; } return true; }
#10 ToUpperCaseCode:public double pow(double base, int exponent) { double result = 1; for (int n = 0; n < exponent; n++) { result = base * result; } return result; } /***or recursive****/ public double pow2(double base, int exponent) { if(exponent == 1){ return base; }else{ return pow2(base, exponent-1) * base; } }
Code:public String toUpperCase(String str) { StringBuffer strBuff = new StringBuffer(); for (int x = 0; x < str.length(); x++) { int cInt = str.charAt(x); if (cInt >= 97) { char temp = (char) (cInt - 32); strBuff.append(temp); } else { strBuff.append(str.charAt(x)); } } return strBuff.toString(); }
taga usctc bai... ang mga compE naay java if naa kay nailhan nga mga 3rd yr up patabang nila. kad2 lng major sa SE(Software Engineering).
Waaaa!! mga master Java man di mu..
Update nko kng unsa wla pa n solve....
11-14-17-18-19-20-22-23-24.......
sa mga nka solve salamat jud kaayo..
c lord nai bhala ninyo... kbw nmu kng kinsa mu...
Problem #8
Code:import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; /** * * @author javapenguin */ public class CheckDuplicates { public static void main(String[] args) { BufferedReader input = new BufferedReader(new InputStreamReader(System.in)); String s = new String(); String ch = new String(); char c = ' '; System.out.println("Please enter a string: "); try { s = input.readLine(); } catch (IOException ex) { System.err.println(ex); } boolean invalid = true; while (invalid) { invalid = false; System.out.println(" "); System.out.println("Please enter a character: "); try { ch = input.readLine(); } catch (IOException ex) { System.err.println(ex); invalid = true; } if (ch.length() != 1) invalid = true; } c = ch.charAt(0); int count = 0; for (int i = 0; i < s.length(); i++) { if (s.charAt(i) == c) count++; } if (count > 1) System.out.println("Duplicate found"); } }
Similar Threads |
|