|登录 |注册

查看: 2104|回复: 11
打印 上一主题 下一主题

谁可以帮我解决这个问题。。。(programming)

[复制链接]
mickyen
2009-7-13 02:43 PM
1.
Input : integer, favNumber string favColor

Using : case

favNUmber                   Favcolor                        output
0< faNumber <= 50            yellow           You will perform well in your exam.
0< faNumber <= 50            green            You are smart and intelligent.
0< faNumber <= 50            Any other color    You have great, passion in programming.
50< faNumber <= 80           yellow           you will be very successful one day.
50< faNumber <= 80           green            You will be a famous programmer one day.
50< faNumber <= 80           Any other color    You will be rich and famous one day
faNumber > 80                Any color         You will hold high position one day.

Example 1
Please enter an integer greater than or equal to 1:
30
Please enter your favourite color:
yellow
You will perform well in your exam.

Example 2
Please enter an integer greater than or equal to 1:
40
Please enter your favourite color:
green
You are smart and intelligent.

Example 3
Please enter an integer greater than or equal to 1:
50
Please enter your favourite color:
red
You have great, passion in programming.

Example 4
Please enter an integer greater than or equal to 1:
60
Please enter your favourite color:
yellow
you will be very successful one day.

Example 5
Please enter an integer greater than or equal to 1:
80
Please enter your favourite color:
green
You will be a famous programmer one day.

Example 6
Please enter an integer greater than or equal to 1:
70
Please enter your favourite color:
red
You will be rich and famous one day

Example 7
Please enter an integer greater than or equal to 1:
90
Please enter your favourite color:
yellow
You will hold high position one day.

Example 8
Please enter an integer greater than or equal to 1:
90
Please enter your favourite color:
green
You will hold high position one day.

Example 9
Please enter an integer greater than or equal to 1:
90
Please enter your favourite color:
red
You will hold high position one day.



2. except using case to do, still got what mode can use?   


我真的不会做。。。快要做到一个头两个大了。。。
请各位大大帮帮忙。。。。。
Super-Tomato
2009-7-13 05:43 PM
原帖由 mickyen 于 2009-7-13 02:43 PM 发表
1.
Input : integer, favNumber string favColor

Using : case

favNUmber                   Favcolor                        output
0< faNumber  



这是很简单的題目,你應該尝试自己做,而不是說不會就把問題丢上來等人幫忙解决, 至少你還有同学可以一起讨论功课,
況且對这科没什么興趣的話大可不必選修這個科目啊


建议妳還是去看看之前你老师所教的基础然后自己动手做,遇到不明白的地方再把你的 coding 放上來讓別人指点問題所在
丧送狂曲
2009-7-13 09:24 PM
很基本呢~好怀念哦~虽然现在还是很嫩...
为什么要用case呢?这个问题根本不适合用case啊

回复 #1 mickyen 的帖子

宅男-兜着走
2009-7-13 10:21 PM
1.
var favcolor:String = "yellow";
favNUmber = 81;
var _case:String;

if(favcolor != "yellow" && favcolor != "green"){
        favcolor="other";
        }

if(favNUmber > 0 && favNUmber <= 50){
        _case = "poor" + favcolor;
        } else if(favNUmber > 50 && favNUmber <= 80){
        _case = "average" + favcolor;
        } else if (favNUmber > 80) {
        _case = "good" + favcolor;       
                }

switch(_case){
        case "pooryellow":
        trace("You will perform well in your exam");
        break;
       
        case "poorgreen":
        trace("You are smart and intelligent.");
        break;
       
        case "poorother":
        trace("You have great, passion in programming");
        break;
       
        case "averageyellow":
        trace("you will be very successful one day.");
        break;
       
        case "averagegreen":
        trace("You will be a famous programmer one day");
        break;
       
        case "averageother":
        trace("You will be rich and famous one day");
        break;
       
        default:
        trace("You will hold high position one day");
        break;
        }

the output is : you will hold high position one day

2. instead of using Switch i rather use if else statement !!!

不懂对不对
不过真的这样switch 会 switch 到死!
Super-Tomato
2009-7-14 02:50 AM
原帖由 宅男-兜着走 于 2009-7-13 10:21 PM 发表
1.
var favcolor:String = "yellow";
favNUmber = 81;
var _case:String;

if(favcolor != "yellow" && favcolor != "green"){
        favcolor="other";
        }

if(favNUmber > 0 && favNUmber  50 && favNUm ...



呵~~~ 初學者當然應該先从 switch...case 和 if..else 開始,等到累积了经验就可以用 array 来完成了
丧送狂曲
2009-7-14 02:31 PM
switch的主要条件是单建输入

例子:1 , 2 , a, b, c~
这样的问题if else 比较适合

回复 #5 Super-Tomato 的帖子

毛毛小子
2009-7-14 02:55 PM
case,if...else,算是common
array 有点复杂,很难上手
还在学习当中

PS:番茄兄,你会用Eclipse吗?我想问些东西

回复 #2 Super-Tomato 的帖子

mickyen
2009-7-14 03:54 PM
我会做if...else的。。。可是老师没教怎样用case 做。。。就要给quiz了。。。所以只好找人求救。。。
mickyen
2009-7-14 03:57 PM
原帖由 丧送狂曲 于 2009-7-13 09:24 PM 发表
很基本呢~好怀念哦~虽然现在还是很嫩...
为什么要用case呢?这个问题根本不适合用case啊



因为老师变态 = =“”em0021
我的programming只会一点点,可是学校老师又讲不清楚,只好只好人叫教。。。em0026
mickyen
2009-7-14 03:59 PM
原帖由 宅男-兜着走 于 2009-7-13 10:21 PM 发表
1.
var favcolor:String = "yellow";
favNUmber = 81;
var _case:String;

if(favcolor != "yellow" && favcolor != "green"){
        favcolor="other";
        }

if(favNUmber > 0 && favNUmber  50 && favNUm ...


谢谢噢。。真的switch都switch死。。em0028
辛好,现在有点搞懂了。。。
谢谢你教我噢。。em0034
您需要登录后才可以回帖 登录 | 注册

JBTALKS.CC |联系我们 |隐私政策 |Share

GMT+8, 2026-1-1 03:19 PM , Processed in 0.095190 second(s), 25 queries .

Powered by Discuz! X2.5 © 2001-2012 Comsenz Inc.

本论坛言论纯属发表者个人意见,与本论坛立场无关
Copyright © 2003-2012 JBTALKS.CC All Rights Reserved

Dedicated Server powered by iCore Technology Sdn. Bhd.

合作联盟网站:
JBTALKS 马来西亚中文论坛 | JBTALKS我的空间 | ICORE TECHNOLOGY SDN. BHD.
回顶部