
正文
门票价格JAVA代码 游客订购机票编程java
提示:扫一扫查出行【扫一扫了解最新限行尾号】
复制提示
求大神帮忙,谢谢!!!!!(要Java代码)
//第一题门票价格JAVA代码的答案门票价格JAVA代码:
import java.util.Scanner;
public class test {
public static void main(String[] args)
{
System.out.println("输入购买金额门票价格JAVA代码:");
Scanner input=new Scanner(System.in);
double a=input.nextDouble();
System.out.println("输入顾客类型(会员或普通)门票价格JAVA代码:");
String b=input.next();
if(b=="会员")
{
if(a=100)
{
a=a*0.8;
System.out.println("需付款门票价格JAVA代码:"+a);
}
else
{
System.out.println("需付款:"+a);
}
}
if(b=="普通")
{
if(a=200)
{
a=a*0.75;
System.out.println("需付款:"+a);
}
else
{
System.out.println("需付款:"+a);
}
}
}
}
//下面是第二题答案:
public class test {
public static void main(String[] args)
{
for(int i = 0; i 3; i++)
{
for(int x = i + 1; x 3; x++)
{
System.out.print(" ");
}
for(int y = 0; y (i + 1) * 2 - 1; y++)
{
System.out.print("*");
}
System.out.println();
}
for(int i = 0; i 4; i++)
{
for(int x = 0; x i; x++)
{
System.out.print(" ");
}
for(int y = i; y 2 * 4 - i - 1; y++)
{
System.out.print("*");
}
System.out.println();
}
}
}
相关问答
Q1: java编程实现景区售票规则:成人票每人10元,儿童票折半(如果儿童身高不超过1.2
这个规则就是设计一个方法门票价格JAVA代码,该方法最后值为一个票价,参数应该是身高,所以有如下代码
public class PriceTest {
public static void main(String[] args) {
int childPrice = getPrice(1.2);
int adultPrice = getPrice(1.5);
System.out.println("1.2米身高门票价格JAVA代码的票价为:"+childPrice);
System.out.println("1.5米身高的成人票价为:"+adultPrice);
}
private static int getPrice(double height) {
return height 1.2?10:5;
}
}
最后结果如下:
Q2: 用java写出商品打折程序
尝试解答一下,这个里面还有老年和教师的判断就省略,主要是打折的代码
import java.util.Scanner;
class Test{
public static void main (String[] args){
Scanner sc = new Scanner(System.in);
System.out.println("请输入消费的金额:");
double oldprice = sc.nextDouble();
double newprice;
if(oldprice = 2000){
newprice = oldprice * 0.85;
}else if(oldprice = 1000 oldprice 2000){
newprice = oldprice * 0.9;
}else
newprice = oldprice;
Judge jud = new Judge();
if(jud.isTeacher()|| jud.isOldman())
newprice = newprice * 0.95;
System.out.println("打折后的价格是:" + newprice);
System.out.println("折扣的程度是: " + newprice / oldprice);
}
}
class Judge{
public boolean isTeacher(){
boolean isTeacher = false;
return isTeacher;
}
public boolean isOldman(){
boolean isOld = false;
return isOld;
}
}
Q3: java编程。订购机票,机票的价格受到季节旺季。淡季影响,而且头等藏跟经济舱的价格也不一同。
public class Ticket {
private int month;
private int classLevel; //1: 头等舱, 2: 经济舱
private int price;
private int basePrice = 5000; //原价
public Ticket(int month, int classLevel) {
this.month = month;
this.classLevel = classLevel;
}
public void showMeThePrice() {
//旺季月份: 4-10
if ((month = 4) (month = 10)) {
if (classLevel == 1) {
price = basePrice * 0.9;
System.out.println("Month: " + month + "; Class: " + classLevel + "; Price: " + price);
} else if (classLevel == 2) {
price = basePrice * 0.8;
System.out.println("Month: " + month + "; Class: " + classLevel + "; Price: " + price);
}
}
// 淡季月份: 1,2,3,11,12
if ((month = 1) (month = 3) || month = 11 || month = 12) {
if (classLevel == 1) {
price = basePrice * 0.5;
System.out.println("Month: " + month + "; Class: " + classLevel + "; Price: " + price);
} else if (classLevel == 2) {
price = basePrice * 0.4;
System.out.println("Month: " + month + "; Class: " + classLevel + "; Price: " + price);
}
}
}
}
测试类:
public class Test {
Ticket myTicket = new Ticket(4, 1); //例如:四月,头等舱
myTicket.showMeThePrice();//输出显示价格
...
}
以上代码全部手打,因为公司没有安装jdk,所以无法测试,你自己调试吧。
Q4: 问一个关于java的程序代码
import java.util.Scanner;
public class colPrice{
public static void main(String[] args){
double[] price = new double[10];
double totalPrice = 0;
System.out.println("请输入商品价格门票价格JAVA代码:");
for(int i=0;i10;i++){
System.out.print(i+1+": ");
Scanner in = new Scanner( System.in);
price[i] = in.nextDouble();
}
System.out.println("");
for(int i= 0;iprice.length;i++){
totalPrice+=price[i];
}
System.out.println("商品总价格是门票价格JAVA代码:"+totalPrice);
}
}
关于门票价格JAVA代码和游客订购机票编程java的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。






