
问下两道关于Java的问题,请各位高手帮个忙,谢谢~
Exercise1:Writeaprograminpseudocode(whichyouturnin,seebelow),thenimplementitinJava,th...
Exercise 1:
Write a program in pseudocode (which you turn in, see below), then implement it in Java, that provides a very simple eDiary capability. The program asks the user for his/her major life event for each of the last 7 days. The program should store these life events in an array. Then, the program should output the life event corresponding to any of the days that the user asks about. Here’s an example of the program’s input and output:
Program: Tell me the major event of day 1
User: I graduated from high school
Program: Tell me the major event of day 2
User: I met John
…
Program: Tell me the major event of day 7
User: I broke up with John
Program: What day would you like to hear about? (Enter 0 to quit)
User: 2
Program: On day 2: I graduated from high school
Program: What day would you like to hear about? (Enter 0 to quit)
User: 0
Program: Bye!
Notice that in the 2nd half of the dialogue, the program continues looping until the user enters 0 to quit. Getting this to work can be a bit tricky, but is important part of this exercise.
You will need to use “Strings” in this exercise. A Java “string” is a sequence of
characters, such as a person’s name, or a sentence of text.
Exercise 2:
If $100 is invested at 6 percent interest, compounded annually, the balance at the end of the first year will be $106 (because the interest is $100 times 6%, which equals $6). The balance at the end of the second year is $112.36 (because the interest is $106 times 6%, which equals $6.36).
Write a program that computes compound interest for any initial amount of money that the user specifies (i.e. it doesn’t work for only the initial amount of $100) and any interest rate (i.e. it doesn’t work for only the interest rate of 6%). The program computes the balance at the end of each year for 100 years, and stores the balances in an array (y0,y2, …, y99). Then, the program asks the user which year s/he is interested in, and the program prints the balance at the end of that year.
Do this exercise in two steps:
1. write your program in pseudocode, and add it (as comments) at the beginning of
your Java program
2. translate your program into Java and run it on a computer 展开
Write a program in pseudocode (which you turn in, see below), then implement it in Java, that provides a very simple eDiary capability. The program asks the user for his/her major life event for each of the last 7 days. The program should store these life events in an array. Then, the program should output the life event corresponding to any of the days that the user asks about. Here’s an example of the program’s input and output:
Program: Tell me the major event of day 1
User: I graduated from high school
Program: Tell me the major event of day 2
User: I met John
…
Program: Tell me the major event of day 7
User: I broke up with John
Program: What day would you like to hear about? (Enter 0 to quit)
User: 2
Program: On day 2: I graduated from high school
Program: What day would you like to hear about? (Enter 0 to quit)
User: 0
Program: Bye!
Notice that in the 2nd half of the dialogue, the program continues looping until the user enters 0 to quit. Getting this to work can be a bit tricky, but is important part of this exercise.
You will need to use “Strings” in this exercise. A Java “string” is a sequence of
characters, such as a person’s name, or a sentence of text.
Exercise 2:
If $100 is invested at 6 percent interest, compounded annually, the balance at the end of the first year will be $106 (because the interest is $100 times 6%, which equals $6). The balance at the end of the second year is $112.36 (because the interest is $106 times 6%, which equals $6.36).
Write a program that computes compound interest for any initial amount of money that the user specifies (i.e. it doesn’t work for only the initial amount of $100) and any interest rate (i.e. it doesn’t work for only the interest rate of 6%). The program computes the balance at the end of each year for 100 years, and stores the balances in an array (y0,y2, …, y99). Then, the program asks the user which year s/he is interested in, and the program prints the balance at the end of that year.
Do this exercise in two steps:
1. write your program in pseudocode, and add it (as comments) at the beginning of
your Java program
2. translate your program into Java and run it on a computer 展开
1个回答
展开全部
大概看了下,需求很简单,但是英文不太好,怕理解错误,所以不直接给你解决问题,最好翻译成中文
更多追问追答
追问
第一题就是让写一个伪码再应用到Java中,让它实现电子字典功能,程序问用户最近七天发生的事,用户输入在最近七天发生的事,然后程序输出对应日期的事情,第一个问题的对话第二个对话中,用户输入0,循环截至,要用到“string”
追答
然后程序输出对应日期的事情 这句话是不是说用户输入一个日期,然后就显示该日期对应的事情
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询