Question: please use python programming language (vs code software ) to help me solve the below quesrions. thanks. 16:54 il 4G Done ICT133_TMA_Jan 2021.pdf Answer all


16:54 il 4G Done ICT133_TMA_Jan 2021.pdf Answer all questions. (Total 100 marks) Question (a) Suppose Jane gets her groceries from several supermarkets, each with a different number of aisles. Suppose Jane gets items from two aisles per supermarket visit, and to reduce the amount of carrying she needs to do, she places a basket at the beginning of one aisle. Assume that Jane will not visit the two aisles more than once Jane wishes to know which aisle she should place her basket so that she can reduce the distance she needs to walk from where she places the basket to the start of the aisle she picks items from, and from the start of the aisle where she picks items from to the basket to place her picked items. Assume the aisles are unit distance from one another Write and express a program to perform the following tasks: Read the number of aisles in the supermarket thut Janet is currently at Read the two aisles Jane needs to get items from. You can assume that we numbers entered are between 1 and the mumber of miles in the supermarket Compute and display the minimum distance she needs to walk to the basket You may apply any algorithm to compute the minimum distance Refer to Figure QI for an example algorithm for how the minimum distance can he computed. Suppose there are 5 aisles in a particular supermarket and Jame needs to pick items from aisle and aisle 4. represented by X. Jame places her basket in front of ausle 3. represented by B. then the distance she needs to walkis (3-1)x2 + (4-3) 2 6 units OD OOO Figure Ol Example Enter eros ir er first sista Enter second as SENGACENIVERSITY COLLEGE 16:54 4G Done ICT133_TMA_Jan 2021.pdf 1CT (b) Make TWO (2) copies of your answer to Question la) and modify a copy for cach of the two parts (i) and (). Your program will first prompt for whether Jane needs to visit one ise If the first non-whitespace character of the input is y case insensitive) the program displays the minimum distance as 0. Otherwise, the program prompts for the number of aisies in the supermarket and the two sides that Jane needs to visit. As in Question the program performs the same computation and displays the minimum distance Examples RI Do y reed to go to sustmesisle Ces/10) The distance is its En 2 Do you need to go to just one all? (y): Enter ruber of sweet Enter first inter second atste The distance to its Your program will first prompt for the number of aisles Jane Does to visit If the number of aisles is 1. the minimum distance is If the number of aisles is 2. the program prompts for the umber of aisles in the supermarket and the two aisles that are needs to visit. As in Question 1a, the program performs the same computation and displays the minimum distance If the number of aisles is any other number other than or 2. the program displays the error message: Invalid number of aisles for Jane! Example Rani Enter the fastest VIII Enter the under of alsies to visit Enter cumber of all ageraret: Enter tirat als Enter Seconds Enter the umber of alles te visits Invalid nader of alles te el mark) 16:55 11 4G Done ICT133_TMA_Jan 2021.pdf Make TWO (2) copies of your answer to Question la) and modify a copy for cach of the two parts (1) and () Your program will first prompt for the number of supermarkets Janelas to visit. For each visit, prompt for the number of aisles the supermarket has and the two aisles Jane has to visit. As in Question at the program performs the same computation and displays the minimum distance for cach supermarket visit Example Enter fallerat Enter tirst aisles Enter cond se The distance its Enter of alles terret Enter first aid er second as The dance 164 er et alt Enter tirasle aber second se Your program will first prompt for the number of aisies the supermarket has. The program then repeatedly prompts for the aisle numbers that one needs to visit. When is entered the input for aisle numbers is terminato The program computes the minimum distance based on the best location Jane place her basket and the number of aisles she needs to pick items from. The program then displays the minimum distance Enter number of the Enter the aisle number to its Enter the aisle u to visit: Enter the asheme to visit Enter these me to visit Enter the alter te visit Enter the aisle number to visit The dance is Ram 2 Ewar under of alles wat Enter the aisle u tu vi Enter the state that The wine distance is Run Enterrumber of sles in swart Enter the aisle number to v (10 marks)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
