
需求描述:
1计费规则:最低2元,超过5站以上每站加收05元,换乘重新起算,例如L1先坐4站,换乘L2再坐6站,结果就是2+25=55元
2程序启动以后读取输入文件(intxt),内容格式如:
L2-8,L2-2
X3,L3-8
每行表示一次行程,起点站和终点站之间用逗号分隔,行数不限
4系统按最短路径方案(尽量少换乘且站数少,假设乘 客换乘一次用的时间相当于坐4个站)规划路线,计算票价,并把路线和票价输出到文件(outtxt),内容格式如:
L2-8,L2-2=25:L2-8,L2-7,L2-6,L2-5,L2-4,L2-3,L2-2
X3,L3-8=4:X3,X4,L3-8
等号后面的表示票价和路径
地铁线路图如下:共有5条线路,X开头的站点表示 换乘车站
写快了没注意,谢谢提醒
public class Computer {
protected int CountValue = 0;
public int getCountValue()
{
return thisCountValue;
}
public Computer(int a){
thisCountValue = a;
}
public void increment()
{
thisCountValue++;
}
public void decrement()
{
thisCountValue--;
}
public void reset()
{
thisCountValue = 0;
}
public static void main(String[] args)
{
Computer com = new Computer(10);
comincrement();
comincrement();
comincrement();
Systemoutprintln(comgetCountValue());
comdecrement();
Systemoutprintln(comgetCountValue());
comreset();
Systemoutprintln(comgetCountValue());
}
}
以上就是关于用Java实现一个地铁票价计算程序,希望给出主要算法与数据结构全部的内容,包括:用Java实现一个地铁票价计算程序,希望给出主要算法与数据结构、java程序编写、等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)