Logical issue in application code - total sum isn't correctHow to mark logical sections of code in Java comments?An issue with logic(Beginner Java issues) Why isn't this code working?Correct usage of OR logical operatorWhy isn't my code calculating the correct total?Method not Returning Correct TotalHow to get the total sumIncorrect total of sum calculationCompiles but total isn't calculatedThe math on the total is not correct

How was the quadratic formula created?

What is the closest airport to the center of the city it serves?

Purpose of のは in this sentence?

Can there be a single technologically advanced nation, in a continent full of non-technologically advanced nations?

How important is people skills in academic career and applications?

String won't reverse using reverse_copy

Fitch Proof Question

What is a smasher?

Would Hubble Space Telescope improve black hole image observed by EHT if it joined array of telesopes?

How can modem speed be 10 times slower than router?

If stationary points and minima are equivalent, then the function is convex?

Should I mention being denied entry to UK due to a confusion in my Visa and Ticket bookings?

Position of past participle and extent of the Verbklammer

I need a disease

Pressure inside an infinite ocean?

How wide is a neg symbol, how to get the width for alignment?

Can a nothic's Weird Insight action discover secrets about a player character that the character doesn't know about themselves?

Is there an idiom that support the idea that "inflation is bad"?

Prove that the limit exists or does not exist

Send iMessage from Firefox

What is the name of this hexagon/pentagon polyhedron?

How to model the curly cable part of the phone

As matter approaches a black hole, does it speed up?

Missing Piece of Pie - Can you find it?



Logical issue in application code - total sum isn't correct


How to mark logical sections of code in Java comments?An issue with logic(Beginner Java issues) Why isn't this code working?Correct usage of OR logical operatorWhy isn't my code calculating the correct total?Method not Returning Correct TotalHow to get the total sumIncorrect total of sum calculationCompiles but total isn't calculatedThe math on the total is not correct






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















I am new to Java and I am not even sure what I am doing is possible.

Do switch case statements and if else statements not play well together?



The requirement of my program is:



  • First ask user for a screen size. If screen size is equals to 13.3, add $200 to the laptop price. If screen size is equals to 15.0 - add $300 to the laptop price. If screen size is equals to 17.3 - add $400 to the laptop price.


  • Ask the user for the CPU type. If CPU type equals to i3, add $150 to the laptop price. If CPU type equals to i5, add $250 to the laptop price. If CPU type equals to i7, add $350 to the laptop price.


  • Ask the user for the RAM size. Add $50 for every 4GB of ram to the laptop price. Then, ask user for storage type. There are 2 options: SSD and HDD. If it's HDD - add $50 to the laptop price for every 500gb. If it's SSD - add $100 to the laptop price for every 500GB.


  • Ask the user for for the screen resolution. There are 2 options, FULLHD and 4K. Add $100 if it's FULLHD screen and $200 if it's 4K screen.



Any help on making my code more readable or any other tips you guys can give me are greatly appreciated!



import java.util.Scanner;

public class laptopConfigurator

public static void main(String[] args)

String screenSize = "";
String cpu = "";
int ram = 0;
String storageType = "";
String screenResolution = "";
int memorySize = 0;
double total= 0.0;

Scanner scan = new Scanner(System.in);

System.out.print("Select screen size:");
screenSize = scan.next();
switch(screenSize)

case("13.3"):
total += 200;
break;

case("15.0"):
total += 300;
break;

case("17.3"):
total += 400;
break;

default: System.out.println("Invalid choice");


System.out.print("Select CPU type:");
cpu = scan.next();
switch (cpu)

case("i3"):
total += 150;
break;

case("i5"):
total += 250;
break;

case("i7"):
total += 350;
break;

default: System.out.println("Invalid choice");


System.out.print("Select RAM size:");
ram = scan.nextInt();
total = total + ram * 50;

System.out.println("Select storage type:");
switch(storageType)

case "SSD":
storageType = "SSD";
break;

case "HDD":
storageType = "HDD";
break;

default: System.out.println("Invalid choice");

System.out.println("Enter memory size:");

memorySize = scan.nextInt();

if (storageType.equals("SSD"))
memorySize = memorySize * 100;
total = total + memorySize;
else if (storageType.equals("HDD"));
memorySize = memorySize * 50;

total = total + memorySize;

System.out.println("Enter screen resolution");
screenResolution = scan.next();
if (screenResolution.equals ("FULLHD"))
total = total +100;
else if (storageType.equals("4K"));
total = total +200;

System.out.println("Laptop price is: "+ total);











share|improve this question



















  • 3





    What exact error do you have?

    – Random Guy
    Mar 22 at 22:37











  • "Select screen size:13.3 Select CPU type:i7 Select RAM size:8 Select storage type: Invalid choice <---------- Run Through Enter memory size: 100 Enter screen resolution 4k Laptop price is: 6150.0"

    – Malice9c
    Mar 22 at 22:42












  • @Malice9c Are you stuck in an error? Is the program compiling successfully? We need the exact ask from you, in order to help you accurately.

    – Red Hunt
    Mar 22 at 22:45











  • I am having a logical error. it compiles sucessufull but runs throught the Select Storage block to print "Invalid choice". I give an input to "select RAM size" and it just prints "select Storage type: invalid choice" without input . Then skips to the next line "enter memory size".

    – Malice9c
    Mar 22 at 22:50


















0















I am new to Java and I am not even sure what I am doing is possible.

Do switch case statements and if else statements not play well together?



The requirement of my program is:



  • First ask user for a screen size. If screen size is equals to 13.3, add $200 to the laptop price. If screen size is equals to 15.0 - add $300 to the laptop price. If screen size is equals to 17.3 - add $400 to the laptop price.


  • Ask the user for the CPU type. If CPU type equals to i3, add $150 to the laptop price. If CPU type equals to i5, add $250 to the laptop price. If CPU type equals to i7, add $350 to the laptop price.


  • Ask the user for the RAM size. Add $50 for every 4GB of ram to the laptop price. Then, ask user for storage type. There are 2 options: SSD and HDD. If it's HDD - add $50 to the laptop price for every 500gb. If it's SSD - add $100 to the laptop price for every 500GB.


  • Ask the user for for the screen resolution. There are 2 options, FULLHD and 4K. Add $100 if it's FULLHD screen and $200 if it's 4K screen.



Any help on making my code more readable or any other tips you guys can give me are greatly appreciated!



import java.util.Scanner;

public class laptopConfigurator

public static void main(String[] args)

String screenSize = "";
String cpu = "";
int ram = 0;
String storageType = "";
String screenResolution = "";
int memorySize = 0;
double total= 0.0;

Scanner scan = new Scanner(System.in);

System.out.print("Select screen size:");
screenSize = scan.next();
switch(screenSize)

case("13.3"):
total += 200;
break;

case("15.0"):
total += 300;
break;

case("17.3"):
total += 400;
break;

default: System.out.println("Invalid choice");


System.out.print("Select CPU type:");
cpu = scan.next();
switch (cpu)

case("i3"):
total += 150;
break;

case("i5"):
total += 250;
break;

case("i7"):
total += 350;
break;

default: System.out.println("Invalid choice");


System.out.print("Select RAM size:");
ram = scan.nextInt();
total = total + ram * 50;

System.out.println("Select storage type:");
switch(storageType)

case "SSD":
storageType = "SSD";
break;

case "HDD":
storageType = "HDD";
break;

default: System.out.println("Invalid choice");

System.out.println("Enter memory size:");

memorySize = scan.nextInt();

if (storageType.equals("SSD"))
memorySize = memorySize * 100;
total = total + memorySize;
else if (storageType.equals("HDD"));
memorySize = memorySize * 50;

total = total + memorySize;

System.out.println("Enter screen resolution");
screenResolution = scan.next();
if (screenResolution.equals ("FULLHD"))
total = total +100;
else if (storageType.equals("4K"));
total = total +200;

System.out.println("Laptop price is: "+ total);











share|improve this question



















  • 3





    What exact error do you have?

    – Random Guy
    Mar 22 at 22:37











  • "Select screen size:13.3 Select CPU type:i7 Select RAM size:8 Select storage type: Invalid choice <---------- Run Through Enter memory size: 100 Enter screen resolution 4k Laptop price is: 6150.0"

    – Malice9c
    Mar 22 at 22:42












  • @Malice9c Are you stuck in an error? Is the program compiling successfully? We need the exact ask from you, in order to help you accurately.

    – Red Hunt
    Mar 22 at 22:45











  • I am having a logical error. it compiles sucessufull but runs throught the Select Storage block to print "Invalid choice". I give an input to "select RAM size" and it just prints "select Storage type: invalid choice" without input . Then skips to the next line "enter memory size".

    – Malice9c
    Mar 22 at 22:50














0












0








0








I am new to Java and I am not even sure what I am doing is possible.

Do switch case statements and if else statements not play well together?



The requirement of my program is:



  • First ask user for a screen size. If screen size is equals to 13.3, add $200 to the laptop price. If screen size is equals to 15.0 - add $300 to the laptop price. If screen size is equals to 17.3 - add $400 to the laptop price.


  • Ask the user for the CPU type. If CPU type equals to i3, add $150 to the laptop price. If CPU type equals to i5, add $250 to the laptop price. If CPU type equals to i7, add $350 to the laptop price.


  • Ask the user for the RAM size. Add $50 for every 4GB of ram to the laptop price. Then, ask user for storage type. There are 2 options: SSD and HDD. If it's HDD - add $50 to the laptop price for every 500gb. If it's SSD - add $100 to the laptop price for every 500GB.


  • Ask the user for for the screen resolution. There are 2 options, FULLHD and 4K. Add $100 if it's FULLHD screen and $200 if it's 4K screen.



Any help on making my code more readable or any other tips you guys can give me are greatly appreciated!



import java.util.Scanner;

public class laptopConfigurator

public static void main(String[] args)

String screenSize = "";
String cpu = "";
int ram = 0;
String storageType = "";
String screenResolution = "";
int memorySize = 0;
double total= 0.0;

Scanner scan = new Scanner(System.in);

System.out.print("Select screen size:");
screenSize = scan.next();
switch(screenSize)

case("13.3"):
total += 200;
break;

case("15.0"):
total += 300;
break;

case("17.3"):
total += 400;
break;

default: System.out.println("Invalid choice");


System.out.print("Select CPU type:");
cpu = scan.next();
switch (cpu)

case("i3"):
total += 150;
break;

case("i5"):
total += 250;
break;

case("i7"):
total += 350;
break;

default: System.out.println("Invalid choice");


System.out.print("Select RAM size:");
ram = scan.nextInt();
total = total + ram * 50;

System.out.println("Select storage type:");
switch(storageType)

case "SSD":
storageType = "SSD";
break;

case "HDD":
storageType = "HDD";
break;

default: System.out.println("Invalid choice");

System.out.println("Enter memory size:");

memorySize = scan.nextInt();

if (storageType.equals("SSD"))
memorySize = memorySize * 100;
total = total + memorySize;
else if (storageType.equals("HDD"));
memorySize = memorySize * 50;

total = total + memorySize;

System.out.println("Enter screen resolution");
screenResolution = scan.next();
if (screenResolution.equals ("FULLHD"))
total = total +100;
else if (storageType.equals("4K"));
total = total +200;

System.out.println("Laptop price is: "+ total);











share|improve this question
















I am new to Java and I am not even sure what I am doing is possible.

Do switch case statements and if else statements not play well together?



The requirement of my program is:



  • First ask user for a screen size. If screen size is equals to 13.3, add $200 to the laptop price. If screen size is equals to 15.0 - add $300 to the laptop price. If screen size is equals to 17.3 - add $400 to the laptop price.


  • Ask the user for the CPU type. If CPU type equals to i3, add $150 to the laptop price. If CPU type equals to i5, add $250 to the laptop price. If CPU type equals to i7, add $350 to the laptop price.


  • Ask the user for the RAM size. Add $50 for every 4GB of ram to the laptop price. Then, ask user for storage type. There are 2 options: SSD and HDD. If it's HDD - add $50 to the laptop price for every 500gb. If it's SSD - add $100 to the laptop price for every 500GB.


  • Ask the user for for the screen resolution. There are 2 options, FULLHD and 4K. Add $100 if it's FULLHD screen and $200 if it's 4K screen.



Any help on making my code more readable or any other tips you guys can give me are greatly appreciated!



import java.util.Scanner;

public class laptopConfigurator

public static void main(String[] args)

String screenSize = "";
String cpu = "";
int ram = 0;
String storageType = "";
String screenResolution = "";
int memorySize = 0;
double total= 0.0;

Scanner scan = new Scanner(System.in);

System.out.print("Select screen size:");
screenSize = scan.next();
switch(screenSize)

case("13.3"):
total += 200;
break;

case("15.0"):
total += 300;
break;

case("17.3"):
total += 400;
break;

default: System.out.println("Invalid choice");


System.out.print("Select CPU type:");
cpu = scan.next();
switch (cpu)

case("i3"):
total += 150;
break;

case("i5"):
total += 250;
break;

case("i7"):
total += 350;
break;

default: System.out.println("Invalid choice");


System.out.print("Select RAM size:");
ram = scan.nextInt();
total = total + ram * 50;

System.out.println("Select storage type:");
switch(storageType)

case "SSD":
storageType = "SSD";
break;

case "HDD":
storageType = "HDD";
break;

default: System.out.println("Invalid choice");

System.out.println("Enter memory size:");

memorySize = scan.nextInt();

if (storageType.equals("SSD"))
memorySize = memorySize * 100;
total = total + memorySize;
else if (storageType.equals("HDD"));
memorySize = memorySize * 50;

total = total + memorySize;

System.out.println("Enter screen resolution");
screenResolution = scan.next();
if (screenResolution.equals ("FULLHD"))
total = total +100;
else if (storageType.equals("4K"));
total = total +200;

System.out.println("Laptop price is: "+ total);








java






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 23 at 15:10









LppEdd

10.1k31749




10.1k31749










asked Mar 22 at 22:34









Malice9cMalice9c

62




62







  • 3





    What exact error do you have?

    – Random Guy
    Mar 22 at 22:37











  • "Select screen size:13.3 Select CPU type:i7 Select RAM size:8 Select storage type: Invalid choice <---------- Run Through Enter memory size: 100 Enter screen resolution 4k Laptop price is: 6150.0"

    – Malice9c
    Mar 22 at 22:42












  • @Malice9c Are you stuck in an error? Is the program compiling successfully? We need the exact ask from you, in order to help you accurately.

    – Red Hunt
    Mar 22 at 22:45











  • I am having a logical error. it compiles sucessufull but runs throught the Select Storage block to print "Invalid choice". I give an input to "select RAM size" and it just prints "select Storage type: invalid choice" without input . Then skips to the next line "enter memory size".

    – Malice9c
    Mar 22 at 22:50













  • 3





    What exact error do you have?

    – Random Guy
    Mar 22 at 22:37











  • "Select screen size:13.3 Select CPU type:i7 Select RAM size:8 Select storage type: Invalid choice <---------- Run Through Enter memory size: 100 Enter screen resolution 4k Laptop price is: 6150.0"

    – Malice9c
    Mar 22 at 22:42












  • @Malice9c Are you stuck in an error? Is the program compiling successfully? We need the exact ask from you, in order to help you accurately.

    – Red Hunt
    Mar 22 at 22:45











  • I am having a logical error. it compiles sucessufull but runs throught the Select Storage block to print "Invalid choice". I give an input to "select RAM size" and it just prints "select Storage type: invalid choice" without input . Then skips to the next line "enter memory size".

    – Malice9c
    Mar 22 at 22:50








3




3





What exact error do you have?

– Random Guy
Mar 22 at 22:37





What exact error do you have?

– Random Guy
Mar 22 at 22:37













"Select screen size:13.3 Select CPU type:i7 Select RAM size:8 Select storage type: Invalid choice <---------- Run Through Enter memory size: 100 Enter screen resolution 4k Laptop price is: 6150.0"

– Malice9c
Mar 22 at 22:42






"Select screen size:13.3 Select CPU type:i7 Select RAM size:8 Select storage type: Invalid choice <---------- Run Through Enter memory size: 100 Enter screen resolution 4k Laptop price is: 6150.0"

– Malice9c
Mar 22 at 22:42














@Malice9c Are you stuck in an error? Is the program compiling successfully? We need the exact ask from you, in order to help you accurately.

– Red Hunt
Mar 22 at 22:45





@Malice9c Are you stuck in an error? Is the program compiling successfully? We need the exact ask from you, in order to help you accurately.

– Red Hunt
Mar 22 at 22:45













I am having a logical error. it compiles sucessufull but runs throught the Select Storage block to print "Invalid choice". I give an input to "select RAM size" and it just prints "select Storage type: invalid choice" without input . Then skips to the next line "enter memory size".

– Malice9c
Mar 22 at 22:50






I am having a logical error. it compiles sucessufull but runs throught the Select Storage block to print "Invalid choice". I give an input to "select RAM size" and it just prints "select Storage type: invalid choice" without input . Then skips to the next line "enter memory size".

– Malice9c
Mar 22 at 22:50













2 Answers
2






active

oldest

votes


















2














String storageType = "";


You never re-assign storageType prior to its usage



System.out.println("Select storage type:");
switch (storageType)
case "SSD":
storageType = "SSD";
break;
case "HDD":
storageType = "HDD";
break;
default:
System.out.println("Invalid choice");



The default branch will always be taken (does this switch have any sense at all?)



System.out.println("Invalid choice");


and subsequent operations using that variable won't be correct, for example



if (storageType.equals("SSD")) 
memorySize = memorySize * 100;
total = total + memorySize;
else if (storageType.equals("HDD"))
;



Both branches will be skipped, and the final price will be wrong.






share|improve this answer




















  • 1





    This means that YOU NEVER ASK for the Storage Type like you did on Screen Size and CPU and such. Add "storageType = scan.next()"

    – chntgomez
    Mar 22 at 22:50












  • Thank you! That was it, (other than my math being off).

    – Malice9c
    Mar 22 at 22:53






  • 1





    @Malice9c advice: when you're stuck on this kind of problems, stop a minute, go away from the computer, than come back and read it from top to bottom

    – LppEdd
    Mar 22 at 22:54



















-2














You need add boolean flags and wrap your menus in while loops. Note: I'm writing this on my phone, so I don't have your code in front of me.



Boolean validRam = false; // same for screen size, etc.
while(!validRam)
// same code as normal
switch(choiceRam)
case "16":
totalCost +=250;
validRam = true; // <--- this line
break;
case "32":
// etc







share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55308646%2flogical-issue-in-application-code-total-sum-isnt-correct%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    2














    String storageType = "";


    You never re-assign storageType prior to its usage



    System.out.println("Select storage type:");
    switch (storageType)
    case "SSD":
    storageType = "SSD";
    break;
    case "HDD":
    storageType = "HDD";
    break;
    default:
    System.out.println("Invalid choice");



    The default branch will always be taken (does this switch have any sense at all?)



    System.out.println("Invalid choice");


    and subsequent operations using that variable won't be correct, for example



    if (storageType.equals("SSD")) 
    memorySize = memorySize * 100;
    total = total + memorySize;
    else if (storageType.equals("HDD"))
    ;



    Both branches will be skipped, and the final price will be wrong.






    share|improve this answer




















    • 1





      This means that YOU NEVER ASK for the Storage Type like you did on Screen Size and CPU and such. Add "storageType = scan.next()"

      – chntgomez
      Mar 22 at 22:50












    • Thank you! That was it, (other than my math being off).

      – Malice9c
      Mar 22 at 22:53






    • 1





      @Malice9c advice: when you're stuck on this kind of problems, stop a minute, go away from the computer, than come back and read it from top to bottom

      – LppEdd
      Mar 22 at 22:54
















    2














    String storageType = "";


    You never re-assign storageType prior to its usage



    System.out.println("Select storage type:");
    switch (storageType)
    case "SSD":
    storageType = "SSD";
    break;
    case "HDD":
    storageType = "HDD";
    break;
    default:
    System.out.println("Invalid choice");



    The default branch will always be taken (does this switch have any sense at all?)



    System.out.println("Invalid choice");


    and subsequent operations using that variable won't be correct, for example



    if (storageType.equals("SSD")) 
    memorySize = memorySize * 100;
    total = total + memorySize;
    else if (storageType.equals("HDD"))
    ;



    Both branches will be skipped, and the final price will be wrong.






    share|improve this answer




















    • 1





      This means that YOU NEVER ASK for the Storage Type like you did on Screen Size and CPU and such. Add "storageType = scan.next()"

      – chntgomez
      Mar 22 at 22:50












    • Thank you! That was it, (other than my math being off).

      – Malice9c
      Mar 22 at 22:53






    • 1





      @Malice9c advice: when you're stuck on this kind of problems, stop a minute, go away from the computer, than come back and read it from top to bottom

      – LppEdd
      Mar 22 at 22:54














    2












    2








    2







    String storageType = "";


    You never re-assign storageType prior to its usage



    System.out.println("Select storage type:");
    switch (storageType)
    case "SSD":
    storageType = "SSD";
    break;
    case "HDD":
    storageType = "HDD";
    break;
    default:
    System.out.println("Invalid choice");



    The default branch will always be taken (does this switch have any sense at all?)



    System.out.println("Invalid choice");


    and subsequent operations using that variable won't be correct, for example



    if (storageType.equals("SSD")) 
    memorySize = memorySize * 100;
    total = total + memorySize;
    else if (storageType.equals("HDD"))
    ;



    Both branches will be skipped, and the final price will be wrong.






    share|improve this answer















    String storageType = "";


    You never re-assign storageType prior to its usage



    System.out.println("Select storage type:");
    switch (storageType)
    case "SSD":
    storageType = "SSD";
    break;
    case "HDD":
    storageType = "HDD";
    break;
    default:
    System.out.println("Invalid choice");



    The default branch will always be taken (does this switch have any sense at all?)



    System.out.println("Invalid choice");


    and subsequent operations using that variable won't be correct, for example



    if (storageType.equals("SSD")) 
    memorySize = memorySize * 100;
    total = total + memorySize;
    else if (storageType.equals("HDD"))
    ;



    Both branches will be skipped, and the final price will be wrong.







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Mar 22 at 22:51

























    answered Mar 22 at 22:47









    LppEddLppEdd

    10.1k31749




    10.1k31749







    • 1





      This means that YOU NEVER ASK for the Storage Type like you did on Screen Size and CPU and such. Add "storageType = scan.next()"

      – chntgomez
      Mar 22 at 22:50












    • Thank you! That was it, (other than my math being off).

      – Malice9c
      Mar 22 at 22:53






    • 1





      @Malice9c advice: when you're stuck on this kind of problems, stop a minute, go away from the computer, than come back and read it from top to bottom

      – LppEdd
      Mar 22 at 22:54













    • 1





      This means that YOU NEVER ASK for the Storage Type like you did on Screen Size and CPU and such. Add "storageType = scan.next()"

      – chntgomez
      Mar 22 at 22:50












    • Thank you! That was it, (other than my math being off).

      – Malice9c
      Mar 22 at 22:53






    • 1





      @Malice9c advice: when you're stuck on this kind of problems, stop a minute, go away from the computer, than come back and read it from top to bottom

      – LppEdd
      Mar 22 at 22:54








    1




    1





    This means that YOU NEVER ASK for the Storage Type like you did on Screen Size and CPU and such. Add "storageType = scan.next()"

    – chntgomez
    Mar 22 at 22:50






    This means that YOU NEVER ASK for the Storage Type like you did on Screen Size and CPU and such. Add "storageType = scan.next()"

    – chntgomez
    Mar 22 at 22:50














    Thank you! That was it, (other than my math being off).

    – Malice9c
    Mar 22 at 22:53





    Thank you! That was it, (other than my math being off).

    – Malice9c
    Mar 22 at 22:53




    1




    1





    @Malice9c advice: when you're stuck on this kind of problems, stop a minute, go away from the computer, than come back and read it from top to bottom

    – LppEdd
    Mar 22 at 22:54






    @Malice9c advice: when you're stuck on this kind of problems, stop a minute, go away from the computer, than come back and read it from top to bottom

    – LppEdd
    Mar 22 at 22:54














    -2














    You need add boolean flags and wrap your menus in while loops. Note: I'm writing this on my phone, so I don't have your code in front of me.



    Boolean validRam = false; // same for screen size, etc.
    while(!validRam)
    // same code as normal
    switch(choiceRam)
    case "16":
    totalCost +=250;
    validRam = true; // <--- this line
    break;
    case "32":
    // etc







    share|improve this answer



























      -2














      You need add boolean flags and wrap your menus in while loops. Note: I'm writing this on my phone, so I don't have your code in front of me.



      Boolean validRam = false; // same for screen size, etc.
      while(!validRam)
      // same code as normal
      switch(choiceRam)
      case "16":
      totalCost +=250;
      validRam = true; // <--- this line
      break;
      case "32":
      // etc







      share|improve this answer

























        -2












        -2








        -2







        You need add boolean flags and wrap your menus in while loops. Note: I'm writing this on my phone, so I don't have your code in front of me.



        Boolean validRam = false; // same for screen size, etc.
        while(!validRam)
        // same code as normal
        switch(choiceRam)
        case "16":
        totalCost +=250;
        validRam = true; // <--- this line
        break;
        case "32":
        // etc







        share|improve this answer













        You need add boolean flags and wrap your menus in while loops. Note: I'm writing this on my phone, so I don't have your code in front of me.



        Boolean validRam = false; // same for screen size, etc.
        while(!validRam)
        // same code as normal
        switch(choiceRam)
        case "16":
        totalCost +=250;
        validRam = true; // <--- this line
        break;
        case "32":
        // etc








        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 22 at 23:00









        jayandsjayands

        108111




        108111



























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55308646%2flogical-issue-in-application-code-total-sum-isnt-correct%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

            Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

            Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript