deng_cen 19 Newbie Poster

hi:
you can do that like that is
package com.structure;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class TestArray {
static List<String> list = new ArrayList<String>();
// static Object[] state;
public static void main(String agrs[]) {
Scanner scan = new Scanner(System.in);
System.out.println("Please input number:");
int num = scan.nextInt();
System.out.println("Please input your String:");
for (int i = 0; i < num; i++) {
list.add((String) scan.next());
}
for (Object str : exchangeArray(list)) {
System.out.println(str);
}
}
public static Object[] exchangeArray(List list) {
return list.toArray();
}
}

deng_cen 19 Newbie Poster

hi:
you can see my code whether help you
package com.structure;
import java.util.ArrayList;
import java.util.List;
public class Text {
String statement;
List<Character> listchar = new ArrayList<Character>();
public Text(String statement) {
super();
this.statement = statement;
exchangeList();
}
private void exchangeList() {
for (int i = 0; i < statement.length(); i++) {
listchar.add(statement.charAt(i));
}
}
public String deleteIndex(int index) {
String temporary="";
listchar.remove(index);
for (Character c : listchar) {
temporary += c;
}
return statement = temporary;
}
public String getStatement() {
return statement;
}
public void setStatement(String statement) {
this.statement = statement;
}
public static void main(String args[]) {
Text text = new Text("this is deng statement");
System.out.println(text.getStatement());
text.deleteIndex(4);
System.out.println(text.getStatement());
}
}

Ezzaral commented: No code tags. Example does little to demonstrate the question. +0
iamthwee commented: Get a life, do your own homework! -2
~s.o.s~ commented: Please be more descriptive and post code using code tags. +24
deng_cen 19 Newbie Poster

hi:
Maybe continue is not neccesary in my codes.but ,I think if ..else..that is very clarity.that is good custom.

deng_cen 19 Newbie Poster

you may add System.out.println("middle");in the middle of two quiz statement.that analysis for "*"

deng_cen 19 Newbie Poster

hi:
you are attendion to that there is only one if in the quiz function.so the * is seven.

deng_cen 19 Newbie Poster

hi,
Maybe this code can help you.

package com.prom1;
import java.util.Scanner;
public class AnalysisTest {
public static void main(String args[]) {
Analysis application = new Analysis(); // create Analysis object
application.processExamResults(); // call method to process results
} // end main
} // end class AnalysisTest
class Analysis {
public void processExamResults() {
// create Scanner to obtain input from command window
// initializing variables in declarations
int passes = 0; // number of passes
int failures = 0; // number of failures
int studentCounter = 1; // student counter
int result; // one exam result (obtains value from user)
Scanner input = new Scanner(System.in);
// process 10 students using counter-controlled loop
while (studentCounter <= 10) {
// prompt user for input and obtain value from user
System.out.print("Enter result (1 = pass, 2 = fail): ");
result = input.nextInt();
// if...else nested in while
if (result == 1) {// if result 1,
passes = passes + 1; // increment passes;
studentCounter = studentCounter + 1;
continue;
} else if (result == 2) {
// else result is not 1, so
failures = failures + 1; // increment failures
studentCounter = studentCounter + 1;
continue;
} else {
System.out.println("that is wrong! Please input number again!");
continue;
}
// increment studentCounter so …

deng_cen 19 Newbie Poster

hi:
you can see this code,but I can't understand that Console meaning.Can you explain that Console Class?

public static void main(String[] args) throws IOException {
  // Variable Declaration
  NumberFormat moneyFormat = NumberFormat.getCurrencyInstance();
  String header = "";
  String footer = "";
  String typeOfDrink = ""; // The available selections on the Drink's
  // menu
  String typeOfSweetness = ""; // The available selections on the
  // Sweetness's menu
  String typeOfMoney = ""; // The available selections on the Money's
  // menu
  String drink = ""; // The selection on the Drink's menu
  String sweetness = ""; // The selection on the Sweetness's menu
  String menuDrink = ""; // The menu of Drinks
  String menuSweetness = ""; // The menu of Sweetness
  String menuMoney = ""; // The menu of Money
  String enter = " ";
  double amountInserted = 0.00; // The Money input from the User
  double change = 0.00; // The change from the Money
  double price = 0.00;
  char optionOfDrink = ' ';
  char optionOfSweetness = ' ';
  char optionOfMoney = ' ';
  char money = ' ';
  int count = 0; // Counter for the invalid input
  boolean mainMenu = false; // Conditions of continuing to second menu
  boolean secondMenu = false; // Conditions of continuing to last menu
  boolean thirdMenu = false;
  boolean limit = false;
  System.out.println(enter);
  // Universal part
  header = "\t\t-----------------------------------------\n      \t\t\tCampus Coffee Machine\n\t\t-----------------------------------------\n";
  footer = "\t\t-----------------------------------------\n\t\tPlease make your selection : ";
  // The structure of available selections of drink
  typeOfDrink = "\t\tA. Espresso\n\t\tB. …
deng_cen 19 Newbie Poster

hi:
you can analyse this coding program
package com.applet;
public class Triangle {
/**
* @param a
* the length of a for the triangle
* @param b
* the length of b for the triangle
* @param c
* the length of c for the triangle
*/
private double a, b, c;
private double angleA, angleB, angleC, area, perimeter;
public Triangle(double a, double b, double c) {
this.a = a;
this.b = b;
this.c = c;
angleA = 0;
angleB = 0;
angleC = 0;
area = 0;
perimeter = 0;
}
public void calculateAngles() {
final double RADIANS_TO_DEGREES = 180 / Math.PI;
angleC = Math.acos((2 * c - 2 * b - 2 * a) / (-2 * a * b))
* RADIANS_TO_DEGREES;
angleB = Math.acos((2 * b - 2 * a - 2 * c) / (-2 * a * b))
* RADIANS_TO_DEGREES;
angleA = Math.acos((2 * a - 2 * c - 2 * b) / (-2 * a * b))
* RADIANS_TO_DEGREES;
}
public double calculateArea() {
double halfperimeter = calculatePerimeter() / 2;
return area = Math.sqrt(halfperimeter * (halfperimeter - a)
* (halfperimeter - b) * (halfperimeter - c));
}
public double calculatePerimeter() {
return perimeter = (a + b + c);
}
public …

iamthwee commented: ur fucking retarded -2
deng_cen 19 Newbie Poster

hi:
your writing which method of arccoseA maybe is wrong!

deng_cen 19 Newbie Poster

hi,everyone:
I want to study jsp,but what am I do,where begin from.I can write java program,Can you help me?:)

deng_cen 19 Newbie Poster

:) hi:
you can see that code.Maybe is right.

package com.jmenu;
public class Fibonacci {
public static void main(String agre[]){
double frontsum=0;
int finditem=3;
double a=Double.parseDouble(agre[0]);
System.out.println(a);
frontsum = calculateItemSum(finditem);
do{
finditem++;
frontsum+=calculateItemSum(finditem);
}while(frontsum<a);
System.out.printf("sum is: %f",frontsum);
System.out.printf("item is: %d",finditem);
System.out.printf("\nitem is: %f",calculateItemSum(96));
System.out.printf("\n -: %f",frontsum-calculateItemSum(96));
}
 
 
 
static double calculateItemSum(int i){
double a=2,b=2,c=0;
int item=3;
while(item<=i){
c=a+b;
a=b;
b=c;
item++;
}
return c;
}
}
deng_cen 19 Newbie Poster

yes ,if infinite loop ,that code
while(true){
}

peter_budo commented: Pointles on comenting somebody else corect solution. Please use full sentences next time. -1
deng_cen 19 Newbie Poster

++i and i++ are all 11 in .net

deng_cen 19 Newbie Poster

try this function:
package com.Thread;
public class DigProd {
public static void main(String args[]) {
long a = 123456789;
long ai = DigProdIterative(a);
System.out.println("Digital Product of a: " + ai);
long ar = Recursive(a);
System.out.println("Digital Product of a: " + ar);
}

public static long doNumRecursive(long a){
long first,y=1;
String str = String.valueOf(a);
if(str.length()==1){
return a;
}
for (int i = 0; i < str.length(); i++) {
int b = str.charAt(i);
b = b - 48; // for ascii code
if (b == 0) {
continue;
} else {
first = str.charAt(i);
first = first - 48;
y = y * first;
}
}
return y;
}

public static long Recursive(long result){
String str = String.valueOf(result);
if(str.length()==1){
System.out.print(result + "\n");
return result;
}else{
System.out.print(result + " --> ");
result=doNumRecursive(result);
str = String.valueOf(result);
if(str.length()==1){
System.out.print(result + "\n");
return result;
}else{
result = Recursive(result);
return result;
}
}
}

public static long DigProdIterative(long a) {
String str = String.valueOf(a);
int first = 1;
long y = a;
while (str.length() != 1) {
str = String.valueOf(y);
if (str.length() == 1) {
System.out.print(y + "\n");
} else {
System.out.print(y + " --> ");
}
y = …