We're a community of 1.1M IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,080,650 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Birthday Party Code

Hi! Guys, My name is Tonie and i just joined Daniweb recently. I have a question that is puzzling me that i wanted to get input from other programmers. The questions is below.

I have a friend who wants to have a party, lets call her Kim. She wants to charge $6.00 for every person and $10.00 per couple. Since Kim is awaiting RSVPs from the invites she sent, she has no idea how many of each will show up. She expects the program to allow her to enter these numbers once she receives the RSVPs, and also output a total dollar amount so she will know how much money she can spend on decorations, etc.

I am new to coding and i just need someone to point me to the right direction. I am not asking for the code without effort but i am asking for ideas on how to start.This is a java program

3
Contributors
3
Replies
6 Hours
Discussion Span
2 Years Ago
Last Updated
4
Views
tonyfingures
Newbie Poster
7 posts since Sep 2010
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

The calculation isn't hard. All you'd need would be some very fundamental arithmetic, a loop, and a branch. If you haven't done so, you should start by reviewing the basics thread stuck to the top of this forum.
You'll want to have done the following:
- get a basic hello world running
- exercise the arithmetic operators and print some results to the screen
- make a for loop that adds up the numbers from 1 to, say, 1000
- modify that loop to omit multiples of 13, that is, to only add number n if n is divisible without remainder by 13.

If you understand those things, you should be able to write this without a hitch, and all of those things you should be able to get at least a good start on from the tutorials.

jon.kiparsky
Posting Virtuoso
1,849 posts since Jun 2010
Reputation Points: 383
Solved Threads: 187
Skill Endorsements: 4

This is what i came up with. I must be doing something wrong because its not working

import javax.swing.JOptionane;

//Author: Tony Fingers
//Purpose: Inputs the number of couples, singles who have RSVP'd and then calculates the total cost of decorations

public class Decorationcost
{
    public static void main(String[]args)
    {
        int dom, number1, number2;


        dom=0;
        number1 = 0;
        number2 = 0;

        dom = Integer .parseInt(JOptionPane.showInputDialog("Enter the guests (1-100) who have RSVP'd."));

        number1 = dom * 6;
        number2 = dom * 10;

        JOptionPane.ShowMessageDialog(null, "Single people who have RSVP'd is: "* number1 * "!");
        JOptionPane.ShowMessageDialog(null, "Couples who have RSVP'd is: " * number2 * "!");

}   //Closes class.
tonyfingures
Newbie Poster
7 posts since Sep 2010
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0
NormR1
Posting Sage
Team Colleague
7,742 posts since Jun 2010
Reputation Points: 1,158
Solved Threads: 793
Skill Endorsements: 16

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page generated in 0.0706 seconds using 2.72MB