嗨,伙计们,我已经修复了最初的问题,但现在它不是正确的加起来。我不确定该做什么,哪里出了问题。如有任何帮助,我们将不胜感激。
导入java.util.scanner;
public类zoo{public static void main(String[]args){
int quantity, confirm, option, finalTotal;
float childTotal = 0;
float adultTotal = 0;
float seniorTotal = 0;
final double childCost = 18;
final double adultCost = 36;
final double seniorCost = 32.50;
int Option[] = new int[3];
Option[0] = 1;
Option[1] = 2;
Option[2] = 3;
boolean continueLoop = true;
char resume;
switch (option) {
case 1:
childTotal=(int) ((double) quantity*childCost) ;
System.out.println("Total amount for child tickets: $" + childTotal);
break;
case 2:
adultTotal=(int) ((double) quantity*adultCost) ;
System.out.println("Total amount for adult tickets $" + adultTotal);
break;
default:
seniorTotal=(int) ((double) quantity*seniorCost);
System.out.println("Total amount for senior tickets $" + seniorTotal);
break;
}
System.out.println("Do you wish to continue? (Y/N) ");
resume = input.next().charAt(0);
switch (option) {
case 1:
finalTotal=(int) ((double) childCost+childTotal);
System.out.println("Total amount for tickets: $" + finalTotal);
break;
case 2:
finalTotal=(int) ((double) adultCost+adultTotal) ;
System.out.println("Total amount for tickets $" + finalTotal);
break;
default:
finalTotal=(int) ((double) seniorCost+seniorTotal);
System.out.println("Total amount for senior tickets $" + finalTotal);
break;
}
我已经修复了问题,并更新了代码以获得更好的性能。
package test;
import java.util.Scanner;
public class CSE1PGX_A2 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
final float childCost = 18;
final float adultCost = 36;
final float seniorCost = 32.50F;
boolean continueLoop = true;
Scanner input = new Scanner(System.in);
float childTotal = 0;
float adultTotal = 0;
float seniorTotal = 0;
while (continueLoop) {
int option, confirm=0;
System.out.println("\t @@@@@ Welcome to Zoos Victoria @@@@@");
System.out.println("\t \t MAIN MENU \n");
System.out.println("\t Zoo has the following ticketing options \n");
System.out.println("\t 1 = Child (4-6 yrs)");
System.out.println("\t 2 = Adult (16+ yrs)");
System.out.println("\t 3 = Senior (60+ yrs) \n");
System.out.println("Enter your option:");
option = input.nextInt();
switch (option) {
case 1: {
System.out.println("Enter total No of tickets for Child:");
int quantity = input.nextInt();
childTotal = quantity * childCost;
System.out.println("You are purchasing " + quantity + " child tickets at " + childCost + " each!");
System.out.println("Press 1 to confirm");
confirm = input.nextInt();
if (confirm == 1) {
System.out.println("Total amount for child tickets: $" + childTotal);
}
break;
}
case 2: {
System.out.println("Enter total No of tickets for Adult:");
int quantity = input.nextInt();
adultTotal = quantity * adultCost ;
System.out.println("You are purchasing " + quantity + " adult tickets at " + adultCost + " each!");
System.out.println("Press 1 to confirm");
confirm = input.nextInt();
if (confirm == 1) {
System.out.println("Total amount for adult tickets $" + adultTotal);
}
break;
}
case 3: {
System.out.println("Enter total No of tickets for Senior:");
int quantity = input.nextInt();
seniorTotal = quantity * seniorCost ;
System.out.println("You are purchasing " + quantity + " senior tickets at " + seniorCost + " each!");
System.out.println("Press 1 to confirm");
confirm = input.nextInt();
if (confirm == 1) {
System.out.println("Total amount for senior tickets $" + seniorTotal);
}
break;
}
}
if (confirm != 1) {
System.out.println("Incorrect key!");
}
System.out.println("Do you wish to continue? (Y/N) ");
char resume = input.next().charAt(0);
if (resume != 'y' && resume != 'Y') {
continueLoop = false;
System.out.println("Total amount for child tickets: $" + childTotal);
System.out.println("Total amount for senior tickets $" + seniorTotal);
System.out.println("Total amount for adult tickets $" + adultTotal);
float finalTotal = childTotal + adultTotal + seniorTotal ;
System.out.println("Total amount payable: $ " + finalTotal);
}
}
}
}
我设计了一个程序,当用户输入“y”时,当询问他们是否希望继续时,它将重新运行。我遇到的问题是,一旦用户输入“n”,程序就应该显示从购买的所有票证选项中支付的总金额。我花了几个星期的时间在这个问题上,不确定下一步该怎么办。我只包含了代码的底部。我还附上了一张照片,以便在程序运行时显示我的问题。 这是我的代码:
我们使用nextjs/reactjs作为FE,并且我们有一个server.js文件,它允许我们在上传映像,但是由于某种原因,每当我们运行服务器时,都会出现错误 下面是我们在server.js上的代码 这些是我们package.json中包含的脚本 希望得到一些答案和建议。这些代码在本地运行,没有任何问题
将android Studio更新到3.1后,我的项目未编译。与Gradle同步时显示错误。 javax.net.ssl.SSLHandshakeException:sun.security.validator.ValidatorException: PKIX路径构建失败:sun.security.provider.certpath.SunCertPathBuilderException:无法找到
问题内容: 我已经在几个线程中看到了答案,但对我却没有解决,而且由于我的问题偶尔发生,因此问这个问题是否有人有任何想法。 我正在使用jedis版本2.8.0,Spring Data Redis版本1.7.5。和redis服务器版本2.8.4用于我们的缓存应用程序。 我有多个缓存保存在redis中,并且从redis获得请求。我正在使用spring数据redis API保存和获取数据。 所有保存和获取
我每5分钟运行一次批处理作业,我不希望其他节点运行同一个作业,因此我使用绝地锁将一个对象锁定5分钟。这样,如果另一个节点试图运行同一个作业,它们就不会得到锁。工作是在获得锁后开始的,当我试图从Redis读取它时,我得到以下异常情况: 这是我的密码 spring启动应用程序。属性文件 作业在开始时执行以下代码以获得锁 之后,redis仓库类试图读取特定模式的值... 这就是我在日志中看到的完全例外。
我成功地获得了20个请求的响应,但无法获得其余10个请求的响应。我面临的问题是,在前20个请求使用了20个连接之后,其余的10个请求无法从池中获得jedis连接,因此我得到以下例外情况: 我已经在网上搜索,但没有找到解决办法。有人能帮我吗?