Facebook Sharer
选择您要替换的背景颜色:
【农历新年】背景图片:
个性化设定
 注册  找回密码
查看: 1879|回复: 11
打印 上一主题 下一主题

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

[复制链接]

1

主题

1

好友

356

积分

超级会员

Rank: 5Rank: 5Rank: 5Rank: 5Rank: 5

跳转到指定楼层
1#
发表于 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?   


我真的不会做。。。快要做到一个头两个大了。。。
请各位大大帮帮忙。。。。。




收藏收藏0

7

主题

1

好友

5108

积分

一流名嘴

Rank: 12Rank: 12Rank: 12

2#
发表于 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 放上來讓別人指点問題所在


回复

使用道具 举报

26

主题

1

好友

2082

积分

白金长老

Rank: 10

3#
发表于 2009-7-13 09:24 PM |只看该作者
很基本呢~好怀念哦~虽然现在还是很嫩...
为什么要用case呢?这个问题根本不适合用case啊


回复

使用道具 举报

46

主题

6

好友

6456

积分

百变名嘴

Rank: 13Rank: 13Rank: 13Rank: 13

4#
发表于 2009-7-13 10:21 PM |只看该作者

回复 #1 mickyen 的帖子

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 到死!


回复

使用道具 举报

7

主题

1

好友

5108

积分

一流名嘴

Rank: 12Rank: 12Rank: 12

5#
发表于 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 来完成了


回复

使用道具 举报

26

主题

1

好友

2082

积分

白金长老

Rank: 10

6#
发表于 2009-7-14 02:31 PM |只看该作者
switch的主要条件是单建输入

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


回复

使用道具 举报

2

主题

0

好友

6008

积分

百变名嘴

Rank: 13Rank: 13Rank: 13Rank: 13

7#
发表于 2009-7-14 02:55 PM |只看该作者

回复 #5 Super-Tomato 的帖子

case,if...else,算是common
array 有点复杂,很难上手
还在学习当中

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


回复

使用道具 举报

1

主题

1

好友

356

积分

超级会员

Rank: 5Rank: 5Rank: 5Rank: 5Rank: 5

8#
发表于 2009-7-14 03:54 PM |只看该作者

回复 #2 Super-Tomato 的帖子

我会做if...else的。。。可是老师没教怎样用case 做。。。就要给quiz了。。。所以只好找人求救。。。


回复

使用道具 举报

1

主题

1

好友

356

积分

超级会员

Rank: 5Rank: 5Rank: 5Rank: 5Rank: 5

9#
发表于 2009-7-14 03:57 PM |只看该作者
原帖由 丧送狂曲 于 2009-7-13 09:24 PM 发表
很基本呢~好怀念哦~虽然现在还是很嫩...
为什么要用case呢?这个问题根本不适合用case啊



因为老师变态 = =“”em0021
我的programming只会一点点,可是学校老师又讲不清楚,只好只好人叫教。。。em0026


回复

使用道具 举报

1

主题

1

好友

356

积分

超级会员

Rank: 5Rank: 5Rank: 5Rank: 5Rank: 5

10#
发表于 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, 2024-10-25 08:29 PM , Processed in 0.129468 second(s), 27 queries .

Powered by Discuz! X2.5

© 2001-2012 Comsenz Inc.

Ultra High-performance Dedicated Server powered by iCore Technology Sdn. Bhd.
Domain Registration | Web Hosting | Email Hosting | Forum Hosting | ECShop Hosting | Dedicated Server | Colocation Services
本论坛言论纯属发表者个人意见,与本论坛立场无关
Copyright © 2003-2012 JBTALKS.CC All Rights Reserved
合作联盟网站:
JBTALKS 马来西亚中文论坛 | JBTALKS我的空间 | ICORE TECHNOLOGY SDN. BHD.
回顶部