I'm not sure if this is in the right section but if it's not, feel free to move this one... :)

I've been really trying hard to get the answers to those questions in our assignment but I can't, and our teacher didn't even explain! :(

SO if someone can help me out, I'd be really thankful. Our teacher wants a pseudo code and a flowchart for the questions. But a psuedo code alone is alright. :)

compute for the total bill for a customer in cafeteria
item prices:
rice=5.00
food(meat)=20
food(vegies)=10
softdrinks=10
input the number of food item and output the total food bill.
ex. rice=10
1meat=20
1vegie=10
total=40
------
compute for the age in years, months, and days from and inputed birth.
------
compute 4 the area and circumference of a circle
------
compute for the area and volume of a cylinder
(those two seems easy but I have no idea how to put it in a psuedo code...


Thanks so much!

Dani AI

Generated

Quick, teacher-friendly pseudocode templates to drop into the assignment. These are written so you can convert each step to a flowchart easily. They respond to s request for plain pseudocode and also address and s point about showing progress—start with these and adapt inputs or item lists as your teacher expects.

Pseudocode for a generic cafeteria total:

# Pseudocode: cafeteria bill
DECLARE prices AS DICTIONARY   // item -> unit price
DECLARE qty AS DICTIONARY      // item -> quantity (read from input)
total <- 0
FOR EACH item IN prices
    q <- qty[item] IF qty[item] EXISTS ELSE 0
    total <- total + prices[item] * q
END FOR
PRINT "Total:", total

Pseudocode to compute age as years, months, days (handles borrowing and leap years):

# Pseudocode: age in years, months, days
FUNCTION days_in_month(y, m)
    IF m IN (1,3,5,7,8,10,12) RETURN 31
    IF m IN (4,6,9,11) RETURN 30
    IF (y % 400 == 0) OR (y % 4 == 0 AND y % 100 != 0) RETURN 29
    RETURN 28
END FUNCTION

READ bd, bm, by    // birth day, month, year
READ cd, cm, cy    // current day, month, year

IF bd > cd
    cm <- cm - 1
    IF cm == 0
        cm <- 12
        cy <- cy - 1
    END IF
    cd <- cd + days_in_month(cy, cm)
END IF

IF bm > cm
    cy <- cy - 1
    cm <- cm + 12
END IF

years <- cy - by
months <- cm - bm
days <- cd - bd
PRINT years, months, days

Circle and cylinder formulas (easy to turn into pseudocode/flowchart):

# Circle
READ r
PI <- 3.14159
area <- PI * r * r
circumference <- 2 * PI * r
PRINT area, circumference

# Cylinder (base area, volume, total surface area)
READ r, h
base_area <- PI * r * r
volume <- base_area * h
lateral_area <- 2 * PI * r * h
surface_area <- 2 * base_area + lateral_area
PRINT base_area, volume, surface_area

Notes: validate inputs (no negative quantities or future birthdates), pick a consistent date format, and test edge cases (leap years, zero radius/height). Converting these blocks into flowchart boxes is straightforward: use loops for the item-sum, decision boxes for borrowing days/months, and simple calculations for geometry.

Recommended Answers

All 2 Replies

How far have you got ??

Post what you have so far. If you have been paying attention at all in class then you should have an idea how to write something in pseudo code. The forums are for getting help - not a magical homework completion service.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.