程序流程:
1.输入用户名称
2.进入考试界面,开始做题
3.系统出题(暂时题固定)
4.用户输入答案,进行判断得分
import java.util.Scanner;
public class Psychology {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
//心理测试,标题
System.out.println("**********************************");
System.out.println(" 心 理 测 试 ");
System.out.println("**********************************");
//输入名字
System.out.println("请输入您的名字:");
String name = input.nextLine();
int sum = 0;
//设置题目
System.out.println("1.你更喜欢吃的水果?\n" + "A.草莓" + "B.苹果" + "C.菠萝" + "D.橘子"+"E.西瓜");
String one = input.next();
if (one.toUpperCase().equals("D")){
sum += 5;
}else if (one.toUpperCase().equals("A")) {
sum += 1;
}else if (one.toUpperCase().equals("B")) {
sum += 2;
}else if (one.toUpperCase().equals("C")) {
sum += 4;
}else{
sum += 3;
}
System.out.println("\n2.你平时休闲经常去的地方?\n" + "A.郊外" + "B.电影院" + "C.公园" + "D.酒吧"+"E.练歌房");
String two = input.next();
if (two.toUpperCase().equals("C")){
sum += 5;
}else if (two.toUpperCase().equals("E")) {
sum += 4;
}else if (two.toUpperCase().equals("B")) {
sum += 3;
}else if (two.toUpperCase().equals("D")) {
sum += 2;
}else{
sum += 1;
}
System.out.println("\n3.你认为容易吸引你的人是?\n" + "A.有才气的人" + "B.依赖你的人" + "C.优雅的人\n" + "D.善良的人"+"E.性格豪放的人");
String three = input.next();
if (three.toUpperCase().equals("C")){
sum += 5;
}else if (three.toUpperCase().equals("D")) {
sum += 4;
}else if (three.toUpperCase().equals("A")) {
sum += 3;
}else if (three.toUpperCase().equals("E")) {
sum += 2;
}else{
sum += 1;
}
System.out.println("\n4.如果你可以成为一种动物,你希望自己是哪种?\n" + "A.猫" + "B.猴子" + "C.狗" + "D.狮子"+"E.大象");
String four = input.next();
if (four.toUpperCase().equals("D")){
sum += 5;
}else if (four.toUpperCase().equals("C")) {
sum += 4;
}else if (four.toUpperCase().equals("E")) {
sum += 3;
}else if (four.toUpperCase().equals("B")) {
sum += 2;
}else{
sum += 1;
}
System.out.println("\n5.天气很热,你更愿意选择什么方式解暑?\n" + "A.游泳" + "B.喝冷饮" + "C.开空调" + "D.心静自然凉");
String five = input.next();
if (five.toUpperCase().equals("C")){
sum += 5;
}else if (five.toUpperCase().equals("B")) {
sum += 4;
}else if (five.toUpperCase().equals("A")) {
sum += 2;
}else{
sum += 1;
}
System.out.println("\n6.如果必须和一个你讨厌的动物或者昆虫在一起生活,你能容忍哪一个?\n" + "A.蛇" + "B.猪" + "C.老鼠" + "D.苍蝇");
String six = input.next();
if (six.toUpperCase().equals("D")){
sum += 5;
}else if (six.toUpperCase().equals("C")) {
sum += 3;
}else if (six.toUpperCase().equals("B")) {
sum += 2;
}else{
sum += 1;
}
System.out.println("\n7.你喜欢看哪类电影、电视剧?\n" + "A.悬疑推理类\n" + "B.童话神话类\n" + "C.自然科学类\n" + "D.道德伦理类\n"+"E.战争枪战类");
String seven = input.next();
if (seven.toUpperCase().equals("E")){
sum += 5;
}else if (seven.toUpperCase().equals("D")) {
sum += 4;
}else if (seven.toUpperCase().equals("A")) {
sum += 3;
}else if (seven.toUpperCase().equals("C")) {
sum += 2;
}else{
sum += 1;
}
System.out.println("\n8.以下那个是你身边必带的物品?\n" + "A.打火机" + "B.口红" + "C.记事本" + "D.纸巾"+"E.手机");
String eight = input.next();
if (eight.toUpperCase().equals("D")){
sum += 5;
}else if (eight.toUpperCase().equals("C")) {
sum += 4;
}else if (eight.toUpperCase().equals("E")) {
sum += 3;
}else if (eight.toUpperCase().equals("A")) {
sum += 2;
}else{
sum += 1;
}
System.out.println("\n9.你出行是喜欢坐什么交通工具?\n" + "A.火车" + "B.自行车" + "C.汽车" + "D.步行");
String nine = input.next();
if (nine.toUpperCase().equals("C")){
sum += 5;
}else if (nine.toUpperCase().equals("B")) {
sum += 3;
}else if (nine.toUpperCase().equals("A")) {
sum += 2;
}else{
sum += 1;
}
System.out.println("\n10.以下颜色你更喜欢哪种?\n" + "A.紫" + "B.黑" + "C.蓝" + "D.红"+"E.白");
String ten = input.next();
if (ten.toUpperCase().equals("E")){
sum += 5;
}else if (ten.toUpperCase().equals("D")) {
sum += 4;
}else if (ten.toUpperCase().equals("C")) {
sum += 3;
}else if (ten.toUpperCase().equals("B")) {
sum += 2;
}else{
sum += 1;
}
System.out.println("\n11.下列运动你最喜欢的(不一定擅长)?\n" + "A.篮球" + "B.自行车" + "C.瑜伽" + "D.蹦极"+"E.乒乓球");
String eleven = input.next();
if (eleven.toUpperCase().equals("A")){
sum += 5;
}else if (eleven.toUpperCase().equals("E")) {
sum += 4;
}else if (eleven.toUpperCase().equals("C")) {
sum += 3;
}else if (eleven.toUpperCase().equals("B")) {
sum += 2;
}else{
sum += 1;
}
System.out.println("\n12.如果你拥有一座别墅,你认为他应在建立在哪里?\n" + "A.城中心" + "B.湖边" + "C.海边" + "D.草原"+"E.郊区");
String twelve = input.next();
if (twelve.toUpperCase().equals("A")){
sum += 5;
}else if (twelve.toUpperCase().equals("C")) {
sum += 4;
}else if (twelve.toUpperCase().equals("B")) {
sum += 3;
}else if (twelve.toUpperCase().equals("E")) {
sum += 2;
}else{
sum += 1;
}
System.out.println("\n13.你更喜欢哪种天气现象?\n" + "A.微风" + "B.雷电" + "C.小雨" + "D.小雪"+"E.雾");
String thirteen = input.next();
if (thirteen.toUpperCase().equals("C")){
sum += 5;
}else if (thirteen.toUpperCase().equals("A")) {
sum += 4;
}else if (thirteen.toUpperCase().equals("D")) {
sum += 3;
}else if (thirteen.toUpperCase().equals("B")) {
sum += 2;
}else{
sum += 1;
}
System.out.println("\n14.你希望自己的窗口在一座30层大楼的第几层?\n" + "A.7层" + "B.18层" + "C.10层" + "D.1层"+"E.30层");
String fourteen = input.next();
if (fourteen.toUpperCase().equals("B")){
sum += 5;
}else if (fourteen.toUpperCase().equals("E")) {
sum += 4;
}else if (fourteen.toUpperCase().equals("C")) {
sum += 3;
}else if (fourteen.toUpperCase().equals("A")) {
sum += 2;
}else{
sum += 1;
}
System.out.println("\n15.你认为自己更喜欢在一下哪个城市中生活?\n" + "A.丽江" + "B.北京" + "C.上海" + "D.杭州"+"E.拉萨");
String fifteen = input.next();
if (fifteen.toUpperCase().equals("B")){
sum += 5;
}else if (fifteen.toUpperCase().equals("C")) {
sum += 4;
}else if (fifteen.toUpperCase().equals("D")) {
sum += 3;
}else if (fifteen.toUpperCase().equals("E")) {
sum += 2;
}else{
sum += 1;
}
System.out.println(name + "的分数是" + sum);
if (sum >= 60){
System.out.println("意志力强,头脑冷静,有较强的领导欲,事业心强,不达目的不罢休。外表和善,内心自傲,对有利自己的人际关系比较看重\n有时显得性格急躁,咄咄逼人,得理不饶人,不利于自己时顽强抗争,不轻易认输。思维理性,对金钱的欲望一般。");
}else if (sum >= 45 && sum < 60){
System.out.println("聪明,性格活泼,人缘好,善于交朋友,心机较深。事业心强渴望成功。思维较理性,崇尚爱情\n但当爱情与婚姻发生冲突时会选择有利于自己的婚姻。金钱欲望强烈。");
}else if (sum >= 30 && sum < 45){
System.out.println("爱幻想,思维较感性,以是否与自己投缘为标准来选择朋友。性格显得较孤傲,有时较急躁,有时优柔寡断。事业心较强,喜欢有创造性的工作\n不喜欢按常规办事。性格倔强,语言犀利,不善于妥协。崇尚浪漫的爱情,但想法往往不切实际,金钱欲望一般。");
}else if (sum >= 15 && sum < 30){
System.out.println("性情温良,重友谊,性格踏实稳重,但有时也比较狡黠。事业心一般,对本职工作能认真对待,但对自己的专业以外的事物没有太大的兴趣喜欢有规律的工作和生活\n不喜欢冒险,家庭观念强,比较善于理财。");
}else{
System.out.println("散漫爱玩、富于幻想。聪明机灵、待人热情、爱交朋友,但对朋友没有严格的选择标准。事业心较差,更善于享受生活,意志力和耐心较差,我行我素\n有较好的异性缘,但对爱情不够坚持认真,容易妥协。没有财产观念。");
}
}
}