MAD Lab functions task
Mon Jul 29 2024 08:22:37 GMT+0000 (Coordinated Universal Time)
Saved by @signup
Date: 29-7-2024 Section: III-I CSE-E Topic: Functions --------------------------------------------------------------------- 1.Write a function named printWelcomeMessage that prints "Welcome to the Online Shopping App!" to the console. 2.Write a function named printGoodbyeMessage that prints "Thank you for visiting the Online Shopping App!" to the console. 3.Write a function named addProduct that takes a String parameter productName and prints "Product <productName> added to the inventory". Note: Call this function with different product names. 4.Write a function named removeProduct that takes a String parameter productName and prints "Product <productName> removed from the inventory.". Note: Call this function with different product names. 5. Write a function named calculateDiscount that takes two Double parameters price and discountRate, and returns the discounted price. Print the returned value in the main function. 6.Write a function named isProductAvailable that takes a String parameter productName and returns true if the product is available in stock, and false otherwise. Print the result in the main function. 7. Write a single-expression function named calculateTax that takes a Double parameter price and returns the tax amount (assume a tax rate of 10%). Print the result in the main function. 8. Write a single-expression function named calculateTotalPrice that takes two Double parameters price and tax and returns their sum. Print the result in the main function. 9. Write a function named createUserAccount that takes a String parameter userName with a default value of "Guest" and prints "User account <userName> created.". Note: Call this function with and without passing a user name. 10. Write a function named applyCoupon that takes a Double parameter discount with a default value of 10.0 and prints "Coupon applied with <discount>% discount.". Note: Call this function with and without passing a discount. 11. Write a function named updateUserProfile that takes three String parameters firstName, lastName, and email, and prints "User profile updated: <firstName> <lastName>, Email: <email>". Call this function using named arguments. 12. Write a function named placeOrder that takes three String parameters productName, deliveryAddress, and paymentMethod, and prints "Order placed for <productName> to be delivered at <deliveryAddress> using <paymentMethod>". note: Call this function using named arguments and print the result.
Comments