23 Mar 2017

Inlab 7 - CSE1002

Do Not Tick option "Request desktop site" anymore while using mobile device.

 

Code:

Choose any one of the following 3:


Shortest Version[Now Verified]:


Fail Safe Version[Verified]:
(in case the book title/Author's Name has spaces in it 
{because in that case simple use of cin will not work since, in a way, the default delimiters are whitespaces so we need to change it to '\n' with getline() }) {as it turns out, the names do not contain spaces so "shortest code" will work this is no longer "recommended" or needed}.
  

Long version[Verified]
( in case you wanted a long version(?) )

Input:

Type of material (0/1)
isbn number
title
author
year of publication
number of pages/duration 

Output:

isbn number
title
cost 

Processing:

for books: 
      cost=pages
for CD:
       cost=2*duration  

Psuedocode: 


start
input type,isbn,title,author,year
if type=0
       input pages
       let cost = pages 
else
      input duration
      let cost = 2*duration
end if
output isbn,title,cost
stop   

5 comments:

  1. wot about skill smugglers code.. that'll work if there are spaces in the name...

    ReplyDelete
  2. um..assuming that that's a question, no, it cannot work if there are spaces or tabs in the input.

    ReplyDelete
  3. plz upload also the copy version

    ReplyDelete
  4. upload as text n not as png!!

    ReplyDelete
  5. Upload as text please

    ReplyDelete