Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 5 of 5

Thread: Whats wrong with my coding

  1. #1
    Junior Member
    Join Date
    Feb 2014
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Whats wrong with my coding

    I cant get the FAQ bit in the alert to work its part of an assignment at college really need help asap



    var help = prompt("Do you need help?");
    if (help ==="yes"){
    myFunction();
    }

    else if(help ==="no"){

    }

    myFunction = function(){
    alert("First enter the height of your room into the box");
    alert("Enter the first length of your room");
    alert("Enter the second length of your room");
    alert("Enter the third length of your room");
    alert("Enter the fourth length of your room");
    alert("Then type in what paint you want your room to be");
    alert("Choose is you want undercoat by typing yes or no");
    alert("Finally the total cost should appear in your box");
    alert("FAQ What happens if I have entered the wrong length... keep pressing cancel and restart");
    alert("FAQ What happens if my house has three walls ... type in three lengths and press 0 for the fourth");
    alert("FAQ What happens if i want one wall one colour and another wall the other...... At the moment this app cant calculate that");
    };

    var height = prompt ("Please enter Your Height");
    var lengthArray = [];
    for ( i = 0 ; i<4; i ++ ){
    var length = prompt ("Please enter your lengths");
    lengthArray.push(length);
    console.log(lengthArray);
    var area = height * length;
    }
    // Paint Cost
    var Economy = 0.45;
    var Standard = 1.00;
    var Luxury = 1.45;
    var underCoat = 0.50;
    var paintCost;
    var undercoatCost;

    // The if stament for the standard costs
    var paintChoice = prompt (" Please Choose your paint ");
    if (paintChoice === "Standard"){
    paintCost = (Standard*area);
    console.log("The cost of this paint will be £ " + paintCost);
    }
    // The if stament for the standard costs
    else if (paintChoice === "Economy"){
    paintCost = (Economy*area);
    console.log("The cost of this paint will be £ " + paintCost);
    }
    // The if stament for the standard costs
    else if (paintChoice === "Luxury"){
    paintCost = (Luxury*area);
    console.log("The cost of this paint will be £ " + paintCost);
    }
    // This is the else if stament for the choice of selecting a wrong colour
    else if (paintChoice === "Red"){
    console.log("You have chosen the wrong paint choice ");
    }
    // This is the the if stament for undercoat when you choose yes
    var underCoat = prompt ("Would you like any undercoat? ");
    if (underCoat === "Yes"){
    undercostCost = (area*underCoat);
    console.log("The cost of the undercoat will be £ " + undercoatCost);
    }
    // This is the else if statement for undercoat when you choose no
    else if (underCoat === "No"){
    console.log("You have chosen not to have undercoat ");
    }
    // This is the variable to total up the lengths
    var total = [];
    var lengthSum = lengthArray[0] + lengthArray[1] + lengthArray[2] + lengthArray[3];
    console.log(lengthSum);
    var area = (height*lengthSum);
    alert("The area of the room is £ " + area.toFixed(2));


  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,517
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: Whats wrong with my coding

    Welcome to the forum! Please read this topic to learn how to post code in code or highlight tags and other useful info for newcomers.
    I cant get the FAQ bit in the alert to work
    What is it? What's it supposed to do? What is it doing?

  3. #3
    Junior Member
    Join Date
    Feb 2014
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Whats wrong with my coding

    Basically it is a app that calculates the cost of painting your room and I have started of with a prompt asking if they need help and if they say yes it gives them steps however i need to link a FAQ into the option of when they choose yes but I cant get it too work

  4. #4
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,517
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: Whats wrong with my coding

    What language is this? JavaScript?

  5. #5
    Junior Member
    Join Date
    Feb 2014
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Whats wrong with my coding

    yeah i posted a new one i fixed this one but the new thread is the hardest fix i need help is there a easier way to chat ?

    --- Update ---

    please i need help need it done by tommorow

Similar Threads

  1. Whats wrong here??
    By cbplayer in forum What's Wrong With My Code?
    Replies: 3
    Last Post: April 16th, 2013, 02:19 PM
  2. WHATS WRONG
    By subodhkr in forum What's Wrong With My Code?
    Replies: 1
    Last Post: September 8th, 2012, 07:47 AM
  3. Whats wrong here?
    By Java Sucks in forum What's Wrong With My Code?
    Replies: 4
    Last Post: June 8th, 2011, 08:33 PM
  4. could you tell me whats wrong....
    By gonfreecks in forum What's Wrong With My Code?
    Replies: 3
    Last Post: November 6th, 2010, 04:35 PM
  5. help whats wrong
    By silverspoon34 in forum What's Wrong With My Code?
    Replies: 4
    Last Post: October 3rd, 2009, 01:41 AM