0

Noise =alram clock :decibles=70.can U provide me a sample solution for this problem?

Write a program that reads a sound level in decibels from the user. If the user enters a decibel level that matches one of the noises in the table then your program should display a message containing only that noise. If the user enters a number of decibels between the noises listed then your program should display a message indicating which noises the level is between. Ensure that your program also generates reasonable output for a value smaller than the quietest noise in the table, and for a value larger than the loudest noise in the table.

14th Aug 2020, 12:49 PM
ÄKoderj
9 Antworten
+ 1
Have you tried this? Is there a code that you have written? Can you share with us your attempt? Below is some pseudo-code I wrote to maybe help get you started. # get user input # if input matches table: return noise level # if input in between matches: return noise level # adjust user input min/max
14th Aug 2020, 1:01 PM
Steven M
Steven M - avatar
+ 1
Actually I dont get it well .that why I cant code the solution
14th Aug 2020, 1:08 PM
ÄKoderj
+ 1
No worries, thank you for being honest and up front, maybe we can work together on a solution. Does something like this help? # get user input volume = int(input()) # if input matches table: return noise level if volume in range(0,101): print("The volume is", volume, "db") else: print("Please enter a number from 0-100") # if input in between matches: return noise level # adjust user input min/max
14th Aug 2020, 1:14 PM
Steven M
Steven M - avatar
+ 1
I think I see what youre doing, does something like this help?... I am not going to write the whole thing :D # get user input volume = int(input()) # if input matches table: return noise level table = {130:'Jackhammer', 106:'Gas lawnmower', 70:'Alarm clock', 40:'Quiet room'} if volume in table: print(table[volume]) # if input in between matches: return noise level # adjust user input min/max
14th Aug 2020, 1:25 PM
Steven M
Steven M - avatar
+ 1
THANKS MILLION THATS IT . THANKS FOR UR TIME FOR HELP .I will contact you privately if U re willing to help in some .how that sounds ?
14th Aug 2020, 1:33 PM
ÄKoderj
+ 1
For the min/max adjustment, I believe the input() is required to be a float and if the float input is less than the quiet room, it is equal to the quiet room and the volume is returned. So, if the input is 20, the program will print 20 and it will print "Quiet Room" Also, if the input is greater than 130, it will print the volume and the Jackhammer. This can all be done with comparison and logical operations https://www.w3schools.com/JUMP_LINK__&&__python__&&__JUMP_LINK/python_operators.asp
14th Aug 2020, 1:33 PM
Steven M
Steven M - avatar
0
Noise. Decibles Quite room. 40 The book provides this table So that number means the noise in that compound adjective phrase ?
14th Aug 2020, 1:10 PM
ÄKoderj
0
It sounds helpful but why the input is integer not string because the problem is focusing on the english words not a number .Another thing U mention 'adjust user input min/max ..How can I do that ? Thanks in advance #Steven M
14th Aug 2020, 1:24 PM
ÄKoderj
0
Interesting .
14th Aug 2020, 1:35 PM
ÄKoderj