• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

coding problem : Discount Offers

 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Guys!

I need a code that works on a sample problem below. I am not a good java programmer and I'm trying to do it too but my solution might be incorrect. You may not use any external libraries to solve this problem, but you may use external libraries or tools for building or testing purposes.

Thank you for your help.



Discount Offers


Our marketing department has just negotiated a deal with several local

merchants that will allow us to offer exclusive discounts on various

products to our top customers every day.

The catch is that we can only offer each product to one customer and we

may only offer one product to each customer.



Each day we will get the list of products that are eligible for these

special discounts.

We then have to decide which products to offer to which of our

customers.

Fortunately, our team of highly skilled statisticians has developed an

amazing mathematical model for determining how likely a given customer

is to buy a given product by calculating what we call the "suitability

score" "SS".

The top-secret algorithm to calculate the "SS" between a customer and a

product is this:



1. If the number of letters in the product's name is even then the "SS" is

the number of vowels in the customer's name

multiplied by 1.5.


2. If the number of letters in the product's name is odd then the "SS" is

the number of consonants in the customer's name.


3. If the number of letters in the product's name shares any common

factors (besides 1) with the number of letters in the customer's name

then the "SS" is multiplied by 1.5.



Your task is to implement a program that assigns each customer a product

to be offered in a way that maximizes the combined total "SS" across all

of the chosen offers.

Note that there may be a different number of products and customers.

You may include code from external libraries as long as you cite the

source.



Input:

Your program should accept as its first argument a path to a

filename. Each line in this file is one test case.

Each test case will contain a set of comma delimited customer names

followed by a semicolon and then a set of comma delimited product names,

" eg.:"

Jack Abraham,
John Evans,
Ted Dziuba;
iPad 2 - 4-pack,
Girl Scouts Thin Mints,
Nerf Crossbow
Jeffery Lebowski,
Walter Sobchak,
Theodore Donald Kerabatsos,
Peter Gibbons,
Michael Bolton,
Samir Nagheenanajar;

Half & Half,
Colt M1911A1,
16lb Bowling ball,
Red Swingline Stapler,
Printer paper,
Vibe Magazine Subscriptions - 40 pack

Output:



For each line of input, print out the maximum total score to two decimal

places,

"eg.:"

21.00
83.50
 
Bartender
Posts: 3225
34
IntelliJ IDE Oracle Spring Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please DoYourOwnHomework
Show us your attempt, we can assit if you are stuck somewhere. Solving the complete problem would not help you to learn
 
Mohamed Sanaulla
Bartender
Posts: 3225
34
IntelliJ IDE Oracle Spring Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And UseAMeaningfulSubjectLine
 
Get me the mayor's office! I need to tell him about this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic