java程序设计,用scanner编写,输入姓名,性别,年龄,住址,婚否,可以输出相应的数据?

java程序设计,用scanner编写,输入姓名,性别,年龄,住址,婚否,可以输出相应的数据?,第1张

package test;

import javautilScanner;  // Import the Scanner class

public class Test{

 public static void main(String[] args) {

   Scanner myObj = new Scanner(Systemin);  // Create a Scanner object

   Systemoutprint("输入年龄:");

   String age= myObjnextLine();  // Read user input

   Systemoutprint("输入姓名:");

   String name= myObjnextLine();  // Read user input

     //再写 地点。。。

   Systemoutprintln(name+" 你好,今年" + age+"岁");  // Output user input

 }}

给你代码,你看一下吧。

------------------------------------------------------------------------------

import javaawtGraphics;

import javaawteventActionEvent;

import javaawteventActionListener;

import javaawteventKeyEvent;

import javaawteventKeyListener;

import javatextDecimalFormat;

import javautilArrayList;

import javautilList;

import javaxswingJButton;

import javaxswingJFrame;

import javaxswingJLabel;

import javaxswingJPanel;

import javaxswingJScrollPane;

import javaxswingJSlider;

import javaxswingeventChangeEvent;

import javaxswingeventChangeListener;

public class GameMain extends JFrame implements KeyListener, ActionListener,

ChangeListener, Runnable {

private List<String> list1 = new ArrayList<String>();

private List<String> list2 = new ArrayList<String>();

private List<String> list3 = new ArrayList<String>();

private List<String> list4 = new ArrayList<String>();

private int intSource = 0;

private JLabel source = null;

private JSlider slider = null;

private boolean isRun = true;

private StringBuffer keyBuff = new StringBuffer();

public GameMain() {

getContentPane()setLayout(null);

JButton btnStart = new JButton("Start");

btnStartsetBounds(12, 10, 93, 23);

btnStartaddActionListener(this);

getContentPane()add(btnStart);

JScrollPane scrollPane = new JScrollPane();

scrollPanesetBounds(12, 95, 420, 300);

getContentPane()add(scrollPane);

JPanel panel = new JPanel() {

public void paint(Graphics g) {

superpaint(g);

paintData(g, list1, 10);

paintData(g, list2, 110);

paintData(g, list3, 210);

paintData(g, list4, 310);

}

};

scrollPanesetViewportView(panel);

JLabel lblSpeed = new JLabel("speed");

lblSpeedsetBounds(126, 15, 50, 13);

getContentPane()add(lblSpeed);

slider = new JSlider(1, 5, 1);

slidersetSnapToTicks(true);

slidersetPaintLabels(true);

slidersetPaintTicks(true);

slidersetPaintTrack(true);

slidersetMajorTickSpacing(1);

slidersetBounds(188, 10, 200, 50);

slideraddChangeListener(this);

getContentPane()add(slider);

JLabel lblSource = new JLabel("source");

lblSourcesetBounds(12, 54, 50, 13);

getContentPane()add(lblSource);

source = new JLabel(intSource + "");

sourcesetBounds(74, 54, 50, 13);

getContentPane()add(source);

addKeyListener(this);

setFocusable(true);

btnStartsetFocusable(false);

slidersetFocusable(false);

setDefaultCloseOperation(EXIT_ON_CLOSE);

setSize(450, 430);

setLocationRelativeTo(null);

setResizable(false);

setVisible(true);

}

public static void main(String[] args) {

new GameMain();

}

public void paintData(Graphics g, List<String> list, int x) {

for (int i = 0; i < listsize(); i++) {

String str = listget(i);

String[] array = strsplit(",");

int y = IntegerparseInt(array[1]);

gdrawString(array[0], x, y);

if (y == 300) {

isRun = false;

break;

}

listremove(i);

y += 10;

listadd(i, array[0] + "," + y);

}

}

public void keyPressed(KeyEvent e) {

}

public void keyReleased(KeyEvent e) {

keyBuffappend(egetKeyChar());

if (keyBufflength() == 3) {

isSource(list1, keyBufftoString());

isSource(list2, keyBufftoString());

isSource(list3, keyBufftoString());

isSource(list4, keyBufftoString());

keyBuffdelete(0, 3);

}

}

public void keyTyped(KeyEvent e) {

}

public void stateChanged(ChangeEvent changeevent) {

setFocusable(true);

}

public void isSource(List<String> list, String str) {

for (int i = 0; i < listsize(); i++) {

String data = listget(i);

if (dataindexOf(str) != -1) {

intSource += 10;

listremove(i);

i--;

}

}

}

public void actionPerformed(ActionEvent e) {

list1clear();

list2clear();

list3clear();

list4clear();

isRun = true;

setFocusable(true);

new Thread(this)start();

}

public String createData(int index) {

DecimalFormat df = new DecimalFormat("00");

int random = (int) (Mathrandom() 1000);

return index + dfformat(random % 100) + ",0";

}

public void run() {

try {

while (isRun) {

list1add(createData(1));

list2add(createData(2));

list3add(createData(3));

list4add(createData(4));

sourcesetText(intSource + "");

repaint();

Threadsleep(1000 / slidergetValue());

}

} catch (Exception e) {

}

}

}

哥们,你也太懒了吧?不过你这个初衷很棒呀。妹子也在泡,专业也在学。所以,既然有此想法,何不努力做出来。

代码就免了。就如同我们做项目一样,首先,你得把需求一条条的明确出来。你的需求是什么样的?是需要怎样的一个表白方式,如:请输入密码(刻意的记住女孩的生日),然后跳转到拼图游戏,这个图就是女孩的照片,赢了过后打印你要表白的话等。又比如:设置一系列问答式的话语,最终筛选出来的梦中女神就是表白对象女生的类型。诸如此类等等。你都可以自己构思如何去表白。每一个对于爱的表达方式不一样。你要选择给美眉一次惊喜还是一次深刻?都取决于你。

你要求代码,估计肯定不会有人给你写。太麻烦了。不过你加上你的构思,在oschina、csdn、cnblogs、iteye等网站去找一些源码应该还是有的。

欢迎分享,转载请注明来源:表白网

原文地址:https://h5.hunlipic.com/biaobai/4114721.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2024-04-17
下一篇2024-04-17

发表评论

登录后才能评论

评论列表(0条)

    保存