java编程。要求:用java编写一个学生成绩管理的小程序,具有增删查改的功能,不需要有界面,不需要特别难。
请高手帮忙,这个学期学习java,是初学者,现在要交作业,因此不需要太难,网上百度的都太复杂了,编写一个容易看懂而且能实现以上功能的,谢谢啦!...
请高手帮忙,这个学期学习java,是初学者,现在要交作业,因此不需要太难,网上百度的都太复杂了,编写一个容易看懂而且能实现以上功能的,谢谢啦!
展开
3个回答
展开全部
User.java
public class User {
private String userName; // 账号
private double amount; // 金额
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public double getAmount() {
return amount;
}
public void setAmount(double amount) {
this.amount = amount;
}
}
BankService.java
import com.bank.po.User;
public interface BankService {
//用户选择操作类型
public void userChoose(String serialNumber);
//开户
public User addUser();
//存款
public User addAmount(User user);
//取款
public User withdrawal(User user);
//查询余额
public void lookBalance(User user);
}
BankServiceImpl.java
import com.bank.po.User;
import com.bank.service.BankService;
import com.bank.util.InputUtil;
public class BankServiceImpl implements BankService{
private static User user;
public void userChoose(String serialNumber){
System.out.println("Please choose the type of operation(Input serial number):");
System.out.println("1 : 开户(Add user)");
System.out.println("2 : 存款(deposit)");
System.out.println("3 : 取款(withdrawals)");
System.out.println("4 : 查询余额(Inquires the balance)");
serialNumber = InputUtil.input();
if("1".equalsIgnoreCase(serialNumber)){
user = addUser();
}else{
if(null != user){
if("2".equalsIgnoreCase(serialNumber)){
user = addAmount(user);
System.out.println("Deposit success !");
}
if("3".equalsIgnoreCase(serialNumber)){
user = withdrawal(user);
System.out.println("Withdrawals success !");
}
if("4".equalsIgnoreCase(serialNumber))
lookBalance(user);
else{
System.out.println("Input is wrong, please input anew !");
}
}else{
System.out.println("Please first open an account");
}
}
userChoose(null);
}
public User addUser() {
User user = new User();
System.out.println("Welcome to use: please first accounts !");
System.out.println("Please enter your user name :");
String userName = InputUtil.input();
System.out.println("Please input amount(please input digital) :");
String amount = InputUtil.input();
user.setUserName(userName);
user.setAmount(Double.parseDouble(amount));
return user;
}
public User addAmount(User user) {
System.out.println("Please input amount(please input digital) :");
String amount = InputUtil.input();
user.setAmount(user.getAmount() + Double.parseDouble(amount));
return user;
}
public User withdrawal(User user) {
System.out.println("Please input amount(please input digital) :");
String amount = InputUtil.input();
user.setAmount(user.getAmount() - Double.parseDouble(amount));
return user;
}
public void lookBalance(User user) {
System.out.println("Your balance for :" + user.getAmount());
}
}
InputUtil.java
public class InputUtil {
public static String input(){
Scanner sc = new Scanner(System.in);
String input = sc.next();
return input;
}
}
测试类
Test.java
import com.bank.service.BankService;
import com.bank.service.impl.BankServiceImpl;
public class Test {
public static void main(String[] args) {
BankService bank = new BankServiceImpl();
bank.userChoose(null);
}
}
自己改吧 很简单的 如果你是做web项目 再说1!
public class User {
private String userName; // 账号
private double amount; // 金额
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public double getAmount() {
return amount;
}
public void setAmount(double amount) {
this.amount = amount;
}
}
BankService.java
import com.bank.po.User;
public interface BankService {
//用户选择操作类型
public void userChoose(String serialNumber);
//开户
public User addUser();
//存款
public User addAmount(User user);
//取款
public User withdrawal(User user);
//查询余额
public void lookBalance(User user);
}
BankServiceImpl.java
import com.bank.po.User;
import com.bank.service.BankService;
import com.bank.util.InputUtil;
public class BankServiceImpl implements BankService{
private static User user;
public void userChoose(String serialNumber){
System.out.println("Please choose the type of operation(Input serial number):");
System.out.println("1 : 开户(Add user)");
System.out.println("2 : 存款(deposit)");
System.out.println("3 : 取款(withdrawals)");
System.out.println("4 : 查询余额(Inquires the balance)");
serialNumber = InputUtil.input();
if("1".equalsIgnoreCase(serialNumber)){
user = addUser();
}else{
if(null != user){
if("2".equalsIgnoreCase(serialNumber)){
user = addAmount(user);
System.out.println("Deposit success !");
}
if("3".equalsIgnoreCase(serialNumber)){
user = withdrawal(user);
System.out.println("Withdrawals success !");
}
if("4".equalsIgnoreCase(serialNumber))
lookBalance(user);
else{
System.out.println("Input is wrong, please input anew !");
}
}else{
System.out.println("Please first open an account");
}
}
userChoose(null);
}
public User addUser() {
User user = new User();
System.out.println("Welcome to use: please first accounts !");
System.out.println("Please enter your user name :");
String userName = InputUtil.input();
System.out.println("Please input amount(please input digital) :");
String amount = InputUtil.input();
user.setUserName(userName);
user.setAmount(Double.parseDouble(amount));
return user;
}
public User addAmount(User user) {
System.out.println("Please input amount(please input digital) :");
String amount = InputUtil.input();
user.setAmount(user.getAmount() + Double.parseDouble(amount));
return user;
}
public User withdrawal(User user) {
System.out.println("Please input amount(please input digital) :");
String amount = InputUtil.input();
user.setAmount(user.getAmount() - Double.parseDouble(amount));
return user;
}
public void lookBalance(User user) {
System.out.println("Your balance for :" + user.getAmount());
}
}
InputUtil.java
public class InputUtil {
public static String input(){
Scanner sc = new Scanner(System.in);
String input = sc.next();
return input;
}
}
测试类
Test.java
import com.bank.service.BankService;
import com.bank.service.impl.BankServiceImpl;
public class Test {
public static void main(String[] args) {
BankService bank = new BankServiceImpl();
bank.userChoose(null);
}
}
自己改吧 很简单的 如果你是做web项目 再说1!
追问
嗯。。。我运行不出来呀,也不知道如何改,不过还是非常感谢
追答
慢慢来吧
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
三张表的小程序?
学生表
课程表
学生课程成绩表?
学生表
课程表
学生课程成绩表?
更多追问追答
追问
就像图片中所示的那样就可以了,对了,再加上一个退出就更好了
追答
学生信息管理。。。 还不是学生成绩管理 数据库都用不到,直接使用一个map存储就行了。
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
我有图书管理系统 ,很简单的小程序
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询