LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > General
User Name
Password
General This forum is for non-technical general discussion which can include both Linux and non-Linux topics. Have fun!

Notices

Reply
 
Search this Thread
Old 04-23-2007, 10:03 AM   #1
pwc101
Senior Member
 
Registered: Oct 2005
Location: UK
Distribution: Slackware
Posts: 1,847

Rep: Reputation: 128Reputation: 128
Scripting the tea making process...


Ok, it's been a slow day at work, so I thought I'd exercise my fortran coding skills (or lack thereof!), and see if I could code the process of making a cup of tea. Does anyone else have any other pointless programs? Is there a website dedicated to this sort of thing? Feel free to post any other ones you've written/seen.

To reiterate, work's going really well today!...
Code:
program tea_break

   implicit none
   integer :: i, bags, mug, biscuit, tea, drink, people
   real :: water, sugar, milk, temp, brewtime

   open (10, file='recipe.dat')
      read (10,*) water, sugar, milk, bags, mug, brewtime, people
   close (10)
   open (20, file='tea.out')

do i=1, people
   if (thirst .gt. 0) then
      do temp=1, 100
         do while (brewtime .lt. 3)
            if (temp .eq. 100) then
            tea=(water*bags)
            else if (temp .lt. 100) exit
            endif
            if (milk .gt. 0) then
               if (sugar .gt. 0) then
               mug=tea+sugar+milk
               else
               mug=tea+milk
            else
               if (sugar .gt. 0) then
               mug=tea+sugar
               else
               mug=tea
            endif
         enddo
      enddo
   endif
   if (biscuit .gt. 0) then
      drink=mug+biscuit
      write(20,*) drink
   else
   write(20,*) mug
   endif
   close (20)
enddo

end program tea_break
 
Old 04-23-2007, 10:11 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,414

Rep: Reputation: 1967Reputation: 1967Reputation: 1967Reputation: 1967Reputation: 1967Reputation: 1967Reputation: 1967Reputation: 1967Reputation: 1967Reputation: 1967Reputation: 1967
can't help noticing no attention is made to the type of spoon being used... could cause a nasty segfault...

sod it... http://www.dangermouse.net/esoteric/ these always make me laugh.
 
Old 04-23-2007, 10:46 AM   #3
dasy2k1
Member
 
Registered: Oct 2005
Location: 127.0.0.1
Distribution: Ubuntu 12.04 X86_64
Posts: 958

Rep: Reputation: 35
try the obfuscated c contest at
www.ioccc.org

or you could try mking tea in Chef:
http://www.dangermouse.net/esoteric/chef.html

Last edited by dasy2k1; 04-23-2007 at 10:50 AM.
 
Old 04-27-2007, 12:33 PM   #4
hacker supreme
Member
 
Registered: Oct 2006
Location: As far away from my username as possible
Distribution: Gentoo
Posts: 259
Blog Entries: 1

Rep: Reputation: 30
My attempt at a Tea break program.

It's coded (very badly) in C. You get extra points for optimising this, and the teabreak.h header file is left as an exercise for the reader.

Code:
#include <stdio.h>
#include "teabreak.h"

int main(){
	if(Tbreak==1){
	findCleanMug();
	if(noMug==true){
		printf("Error: No Clean Mugs.\nThis program requires =>1 Clean Mug to run.\n");
		exit _IN_A_MOOD_;
	}
	else{
		if(beverage=='Tea'){
			put(_TEABAG_,_CUP_);
			put(_SUGAR_,_CUP_);
			put(_WATER_,_CUP_);
			put(_MILK_,_CUP_);
			exit _HAPPY_;
			}
		else if(beverage=='Coffee'){
			put(_COFFEE_,_CUP_);
			put(_SUGAR_,_CUP_);
			put(_WATER_,_CUP_);
			put(_MILK_,_CUP_);
			exit _HAPPY_;
			}
		else if(beverage=='Decaf'){
			printf("Decaf? What good is that?\n");
			put(_ESPRESSO_,_CUP_);
			put(_SUGAR_,_CUP_);
			put(_WATER_,CUP_);
			put(_MILK_,_CUP_);
			exit _COMPLETELY_WIRED_;
			}
			else if(beverage=='Alcohol'){
				while(stillStanding){
				put(_VODKA_,_CUP_);
				put(_MORE_VODKA_,_CUP_);
				drink(_CUP_);
				put(_VODKA_,_CUP_);
				put(_MORE_VODKA_,_CUP_);
				drink(_CUP_);
				}
				fallOver();
				fallAsleep();
				/* This can't happen */
				if(awake==1){
					exit _WITH_HEADACHE_;
				}
			}
			else{
				printf("Error: No beverage selected.\n");
				exit _STILL_THIRSTY_;
			}
			
	}
	}
	else{
		keepWorking();
		exit _IMPATIENT_;
	}
/* shouldn't get here... */
exit _CONFUSED_;
}
I left out the error checking due to this being a pre-pre-pre-pre-alpha program. Don't try to run this program without error checking, it could possibly do a fandango on core, which is a Bad Thing.

I try...
 
Old 04-28-2007, 05:47 PM   #5
brianL
LQ 5k Club
 
Registered: Jan 2006
Location: Oldham, Lancs, England
Distribution: Slackware & Slackware64 14.1
Posts: 7,076
Blog Entries: 52

Rep: Reputation: Disabled
Thought it worked OK, but then I got sugar and milk in my vodka. Please try again.
 
Old 04-28-2007, 07:19 PM   #6
hacker supreme
Member
 
Registered: Oct 2006
Location: As far away from my username as possible
Distribution: Gentoo
Posts: 259
Blog Entries: 1

Rep: Reputation: 30
Ok, brianL, that will be looked into.
I see some major restructuring to be done before version 1 is stable enough to be released.

EDIT: I have just read the entire source of teabreak and I can't see how you got Milk and Sugar in your vodka.

Last edited by hacker supreme; 04-29-2007 at 10:56 AM.
 
Old 05-01-2007, 05:33 AM   #7
hacker supreme
Member
 
Registered: Oct 2006
Location: As far away from my username as possible
Distribution: Gentoo
Posts: 259
Blog Entries: 1

Rep: Reputation: 30
After much intensive testing, we have come to the conclusion that this is not a bug,this is an undocumented feature
 
Old 05-01-2007, 06:22 AM   #8
brianL
LQ 5k Club
 
Registered: Jan 2006
Location: Oldham, Lancs, England
Distribution: Slackware & Slackware64 14.1
Posts: 7,076
Blog Entries: 52

Rep: Reputation: Disabled
I've done extensive testing too, and noticed that after 10 glasses I don't mind the milk and sugar.
 
Old 05-01-2007, 06:49 AM   #9
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,414

Rep: Reputation: 1967Reputation: 1967Reputation: 1967Reputation: 1967Reputation: 1967Reputation: 1967Reputation: 1967Reputation: 1967Reputation: 1967Reputation: 1967Reputation: 1967
could you pretend it's a pina colada?
 
Old 05-01-2007, 07:58 AM   #10
brianL
LQ 5k Club
 
Registered: Jan 2006
Location: Oldham, Lancs, England
Distribution: Slackware & Slackware64 14.1
Posts: 7,076
Blog Entries: 52

Rep: Reputation: Disabled
After 10 glasses I don't mind pretending anything....Why is the ceiling where the floor used to be? wGoooz muvigg the keuss on my Ketbosrd? OOOOOOOh, where's the bucket...
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
making user friendly screen through shell scripting Prasun1 Linux - General 7 07-09-2005 05:31 AM
scripting module making & installing linuxhippy Slackware 2 03-24-2005 07:30 PM
spilled tea on my keyboard and need to disable it... kenkajoto Linux - Hardware 10 12-04-2004 01:35 PM
scripting a find, cp and bzip2 then scp process onewhoknows Linux - Newbie 2 06-08-2004 07:05 AM
Bash Scripting - child process affecting parent process mthaddon Linux - General 1 05-02-2004 02:19 PM


All times are GMT -5. The time now is 11:46 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration