成都网站建设设计

将想法与焦点和您一起共享

庆祝生日的java代码 用java做一个生日快乐的程序

用简单java循环实现生日问候

我加的import java.util.Date;和你老师说的import java.util.*;一样,那我改成你那种把

创新互联-专业网站定制、快速模板网站建设、高性价比临海网站开发、企业建站全套包干低至880元,成熟完善的模板库,直接使用。一站式临海网站制作公司更省心,省钱,快速模板网站建设找我们,业务覆盖临海地区。费用合理售后完善,十年实体公司更值得信赖。

我写的应该是最简单的了,里面还写了很多注释,你可以看看,其实你新学习,坑农是看这些东西有点眼晕,别晕,其实都是很简单的,JAVA的最大特点就是他有很多别人写好的东西,调用就可以了,你不认识的就当是调用了

import java.util.*;

import javax.swing.JOptionPane;

public class Test93 {

public static void main(String[] args) {

System.out.println("我行我素购物管理系统生日问候");

//这是一个死循环,需要后面的break跳出

while (true) {

Date dt = new Date();

//dt就是获得的当前系统信息,下面用date的分别取今天的月份和日子

//注意月份要加1

//这里用Calendar会更好,但是貌似你要用date

int month = dt.getMonth() + 1;

int date = dt.getDate();

//用对话框提示用户,并得到用户的输入

String id = JOptionPane.showInputDialog(null, "请输入您的会员编号:");

String str = JOptionPane.showInputDialog(null, "请输入您的生日:");

String month2 = str.substring(0, 2);

String date2 = str.substring(3, 5);

//转换得到的字符串,和月份,日子分别比较

if (month == (Integer.parseInt(month2))

date == (Integer.parseInt(date2))) {

//一致就通知获奖,并结束程序

System.out.println("第一个产生的寿星为:"+id+" 获赠一个三星手机");

break;

} else {

//不一致继续循环

System.out.println("今天不是您的生日");

String str2 = JOptionPane.showInputDialog(null, "继续Y/N?");

//如果用户输入N则系统结束,大写小写N都可以

if ("N".equals(str2) || "n".equals(str2)) {

break;

}

}

}

}

}

最后再不愁一句,你把这个格式给修修,比如缩进什么的会更清晰,可以用eclipse 的ctrl+shift+f的快捷键

呵呵加油

生日代码怎么弄手机

编写一个简单的生日快乐APP

一、关闭之前的helloworld程序

点击file,然后close project,就完成关闭了。

二、创建一个新的happybirthday程序

三、下面开始整个APP的修改

1、如何查看Androidstudio中activity_main.xml的源代码,在图中 灰色部分现在是Design,点到code就会出现activity_main_xml的代码了。

2、进行如下代码的修改。把根布局改成相对布局 androidx.constraintlayout.widget.ConstraintLayout改为RelativeLayout

把多余的代码删除掉 ,并将文本内容改为android:text="祝你生日快乐!"

app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintRight_toRightOf="parent" app:layout_constraintTop_toTopOf="parent"

并可以修改文字的大小,颜色,添加边框.。代码如下:

3、在左侧目录下,res是存放资源文件的(图片放进来);java是存放java代码的;mainfests是存放配置文件的。因此将图片复制在最侧res目录下。

4、将代码补充完整

代码:

?xml version="1.0" encoding="utf-8"?

RelativeLayout xmlns:android=""

xmlns:app=""

xmlns:tools=""

android:layout_width="match_parent"

android:layout_height="match_parent"

tools:context=".MainActivity"

TextView

android:layout_margin="20dp"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="祝你生日快乐!"

android:textColor="@android:color/holo_orange_light"

android:textSize="22dp"

/

ImageView

android:layout_centerInParent="true"

android:src="@drawable/img"

android:layout_width="match_parent"

android:layout_height="wrap_content" /

/RelativeLayout

5、最后的效果如图所示

6、可在手机中看到happybirthday的程序包,打开便是上面的画面。

求大神帮忙,好朋友过生日,喜欢五月天,求一个java代码写的程序做生日礼物!

classBirth{privateStringbirth;privateStringsname;privateStringinterest;privateStringbook;privateStringfilm;publicvoidsetBirth(Stringbirth){this.birth=birth;}publicvoidsetName(Stringsname){this.sname=sname;}publicvoidsetInterest(Stringinterest){this.interest=interest;}publicvoidsetBook(Stringbook){this.book=book;}publicvoidsetFilm(Stringfilm){this.film=film;}publicStringgetBirth(){returnbirth;}publicStringgetName(){returnsname;}publicStringgetInterest(){returninterest;}publicStringgetBook(){returnbook;}publicStringgetFilm(){returnfilm;}publicvoidoutPut(){System.out.println("YourNameis:"+this.getName());System.out.println("YourBirthis:"+this.getBirth());System.out.println("YourInterestis:"+this.getInterest());System.out.println("YourBookis:"+this.getBook());System.out.println("Yourfilmis:"+this.getFilm());}}publicclassTestBirth{publicstaticvoidmain(String[]args){Birthbr=newBirth();br.setName("xuwenpeng");br.setBirth("1987/03/04");br.setInterest("basketball");br.setFilm("aidefengxiang");br.setBook("java");br.outPut();}}Result:YourNameis:xuwenpengYourBirthis:1987/03/04YourInterestis:basketballYourBookis:javaYourfilmis:aidefengxiang


分享标题:庆祝生日的java代码 用java做一个生日快乐的程序
标题URL:http://chengdu.cdxwcx.cn/article/ddeepps.html