|
查看: 1299|回复: 13
|
Java 救救我啊~~~大家帮忙一下
[复制链接]
|
|
|
有个问题是这样的:1. Writea program that ask the user how ,many lines to print, how many stars to printeach line:Line?3Starsper line?13***************************************我做到的只是前面的,可是当我要从user的input那里在show出来要用什么code呢?import java.io.*;class ques3{ public static void main(String [ ]args)throws IOException { BufferedReader stdin= new BufferedReader(new InputStreamReader(System.in)); String inData; int num,y; System.out.println("How many line you like to print?"); inData=stdin.readLine(); num=Integer.parseInt( inData); System.out.println("How many star you like to print?"); inData=stdin.readLine(); y=Integer.parseInt(inData); }}有谁知道呢?游
[ 本帖最后由 科技小女孩 于 13-4-2009 10:44 AM 编辑 ] |
|
|
|
|
|
|
|
|
|
|
发表于 22-2-2009 04:10 PM
|
显示全部楼层
import java.io.*;
class ques3
{
public static void main(String [ ]args)throws IOException
{
BufferedReader stdin= new BufferedReader(new InputStreamReader(System.in));
String inData1,inData2;
int num,y,i,j;
System.out.println("How many line you like to print?");
inData1=stdin.readLine();
num=Integer.parseInt( inData1);
System.out.println("How many star you like to print?");
inData2=stdin.readLine();
y=Integer.parseInt(inData2);
for(i=0;i<num;i++){
for(j=0;j<y;j++){
System.out.print('*');}
System.out.println();
}
}
}
献丑了,我只会写小program |
|
|
|
|
|
|
|
|
|
|

楼主 |
发表于 22-2-2009 04:23 PM
|
显示全部楼层
原帖由 basic 于 22-2-2009 04:10 PM 发表 import java.io.*;class ques3{ public static void main(String [ ]args)throws IOException { BufferedReader stdin= new BufferedReader(new InputStreamReader(System.in)); String inData1,i ...
哦,原来是这样子
我一直想都想不到,谢谢你basic哦 |
|
|
|
|
|
|
|
|
|
|

楼主 |
发表于 28-2-2009 12:34 PM
|
显示全部楼层
再来一个关于array的
question: write a program to accept 10 numbers and store into an array then find the average of the 10 numbers.
import java.io.*;
class ques2{
public static void main(String args[ ])throws IOException{
BufferedReader stdin= new BufferedReader(new InputStreamReader(System.in));
String inputData1;
int ten_number[ ]=new int[11];
int total[ ]=new int[2];
for(int x=0;x<11;x++)
{
System.out.print("Please enter 10 number that you like:");
inputData1=stdin.readLine();
ten_number[x]=Integer.parseInt(inputData1);
}
System.out.print("Average of 10 number:"+(ten_number[x]/10));
}
}
接下去要怎样? |
|
|
|
|
|
|
|
|
|
|
发表于 28-2-2009 06:01 PM
|
显示全部楼层
|
|
|
|
|
|
|
|
|
|

楼主 |
发表于 28-2-2009 06:19 PM
|
显示全部楼层
原帖由 basic 于 28-2-2009 06:01 PM 发表 import java.util.Scanner;class ques2{public static void main(String args[ ]){Scanner input = new Scanner(System.in);int ten_number[ ]=new int[10];int total=0;for(int x=0;x 不过这个我没有学过哦
我在北海的工艺学院读
你呢? |
|
|
|
|
|
|
|
|
|
|
发表于 28-2-2009 10:47 PM
|
显示全部楼层
|
|
|
|
|
|
|
|
|
|

楼主 |
发表于 1-3-2009 10:30 AM
|
显示全部楼层
|
|
|
|
|
|
|
|
|
|

楼主 |
发表于 13-4-2009 10:43 AM
|
显示全部楼层
hello
我又来了
我又有问题了
想问哦
i would like to create a program that will receive a string from the keyboard and count the number of vowels in the string. now the problem is i use this string s.indexOf() but still can't get
有谁可以帮我吗? |
|
|
|
|
|
|
|
|
|
|
发表于 13-4-2009 09:30 PM
|
显示全部楼层
|
|
|
|
|
|
|
|
|
|
发表于 13-4-2009 09:36 PM
|
显示全部楼层
String a = "abcde";
int c = 0 ;
for (int b = 0 ; b < a.length() ; b++) {
if (a.charAt(b) == 'a' || a.charAt(b) == 'e') {
c++;
}
} |
|
|
|
|
|
|
|
|
|
|

楼主 |
发表于 15-4-2009 07:23 PM
|
显示全部楼层
原帖由 兔仙人 于 13-4-2009 09:36 PM 发表 String a = "abcde"; int c = 0 ; for (int b = 0 ; b < a.length() ; b++) { if (a.charAt(b) == 'a' || a.charAt(b) == 'e') { c++; } } 我做到了,可是怎样把全部的vowel算起来呢?
我的code;
import java.io.*;
class countvowel
{
static DataInputStream s=new DataInputStream(System.in);
public static void main(String args [])throws IOException
{
String anyvowel;
System.out.println("Enter a string: ");
anyvowel=s.readLine();
System.out.println("String: "+anyvowel);
System.out.println();
int c = 0 ;
for (int b = 0 ; b < anyvowel.length() ; b++) {
if (anyvowel.charAt(b) == 'a' || anyvowel.charAt(b) == 'e'||anyvowel.charAt(b)=='i'||anyvowel.charAt(b)=='o'||anyvowel.charAt(b)=='u') {
c++;
System.out.println("The vowel that have in the string:"+ anyvowel.charAt(b));
}
}
}
}
[ 本帖最后由 科技小女孩 于 15-4-2009 09:14 PM 编辑 ] |
|
|
|
|
|
|
|
|
|
|
发表于 15-4-2009 09:38 PM
|
显示全部楼层
回复 12# 科技小女孩 的帖子
System.out.println("The vowel that have in the string:"+ anyvowel.charAt(b));
}
}
下面加
System.out.println("The total number of vowel in the string:" + c ); |
|
|
|
|
|
|
|
|
|
|

楼主 |
发表于 16-4-2009 08:20 AM
|
显示全部楼层
原帖由 wuichia 于 15-4-2009 09:38 PM 发表 System.out.println("The vowel that have in the string:"+ anyvowel.charAt(b));}}下面加System.out.println("The total number of vowel in the string:" + c ); 谢谢你,我做到了 |
|
|
|
|
|
|
|
|
| |
本周最热论坛帖子
|