Java

 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me



Go Back   Tutorialized ForumsWeb Design & DevelopmentJava

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Tutorialized Forums Sponsor:
  #1  
Old September 27th, 2013, 07:48 AM
love19801 love19801 is offline
Registered User
Tutorialized Newbie (0 - 499 posts)
 
Join Date: Sep 2013
Posts: 1 love19801 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 m 57 sec
Reputation Power: 0
I have a Java question pertaining to if/else statements that I'm having trouble with

For the record, the work is entirely optional, and is not graded. However, I want to thoroughly learn the course material, so I'm working on the additional practice questions in MyProgrammingLab. Here is my question:

Online Book Merchants offers premium customers 1 free book with every purchase of 5 or more books and offers 2 free books with every purchase of 8 or more books. It offers regular customers 1 free book with every purchase of 7 or more books, and offers 2 free books with every purchase of 12 or more books. Write a statement that assigns freeBooks the appropriate value based on the values of the boolean variable is Premium Customer and the int variable books Purchased

Here is my code thus far. The error states that I'm using an incorrect number somewhere in my solution:

if (nbooksPurchased >= 5 && nbooksPurchased <= 7)
{
if (isPremiumCustomer = true)
{
freeBooks ==1;
}
}
else if (isPremiumCustomer = false)
{
if (nbooksPurchased >= 7 && nbooksPurchased <= 12)
{
freeBoks ==1;
}
}
else if (nbooksPurchased >= 8)
{
if (isPremiumCustomer = true)
{
freeBooks ==2;
}
}
else if (isPremiumCustomer = false)
{
if (nbooksPurchased >= 12)
{
freeBooks ==2;
}
}

Additional Details
Alright, after making that initial fix, and changing my typo (freeBoks, lol), the program claims that the variable freeBooks may not be initialized. I think this may be the last error in the code. Here is the modified code that I have:

if (nbooksPurchased >= 5 && nbooksPurchased < 8)
{
if (isPremiumCustomer == true)
{
freeBooks = 1;
}
}
else if (isPremiumCustomer == false)
{
if (nbooksPurchased >= 7 && nbooksPurchased < 12)
{
freeBooks = 1;
}
}
else if (nbooksPurchased >= 8)
{
if (isPremiumCustomer == true)
{
freeBooks = 2;
}
}
else if (isPremiumCustomer == false)
{
if (nbooksPurchased >= 12)
{
freeBooks = 2;
}
}
else
freeBooks = 0;

Any help would be appreciated.
Thanks in advance.

Reply With Quote
Reply

Viewing: Tutorialized ForumsWeb Design & DevelopmentJava > I have a Java question pertaining to if/else statements that I'm having trouble with


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 

Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.

© 2003-2017 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap