Program 258: Online Shopping Program using C
Online Shopping including Change in Quantity
Explanation:
//Coming Soon
Output:
#include<stdio.h> #include<string.h> main() { static int totalCost; int i,j,choice,c=1,a[9],cost[9]; for(i=0;i<9;i++) a[i]=0; char str[100]; char items[9][100]={"Sandisk 16 GB", "Logitech Mouse", "Pendrve 16 GB", "Adidas", "Nike", "Leecooper", "Mi Note 3", "Nokia 3", "Samsung" }; printf("Please Enter Your Name\n"); gets(str); printf("Hello %s, Welcome to our Online Shopping.\n",str); do{ //C is 1 by default if(c==1){ printf("Enter\n1 - Computer Accessories\n2 - Shoes\n3 - Mobiles\nAny other number to exit\n"); scanf("%d",&choice); switch(choice) { case 1: { int accessoriesChoice; printf("Enter\n1 - Sandisk 16 GB - Rs.355\n2 - Logitech Mouse- Rs.500\n3 - Pendrive 16 GB - Rs.550\nAny other number to exit\n"); scanf("%d",&accessoriesChoice); cost[0]=355; cost[1]=500; cost[2]=550; switch(accessoriesChoice) { case 1: { int num; printf("You chose Sandisk 16GB with Rs.355.Are you sure to buy.If 'Yes' Enter 1 else any number\n"); scanf("%d",&num); if(num==1) { a[0]++; totalCost+=355; } printf("Your Cost in Cart is %d\n",totalCost); break; } case 2: { int num; printf("You chose Logitech Mouse with Rs.500.Are you sure to buy.If 'Yes' Enter 1 else any number\n"); scanf("%d",&num); if(num==1) { a[1]++; totalCost+=500; } printf("Your Cost in Cart is %d\n",totalCost); break; } case 3: { int num; printf("You chose Pendrive 16GB with Rs.550.Are you sure to buy.If 'Yes' Enter 1 else any number\n"); scanf("%d",&num); if(num==1) { a[2]++; totalCost+=550; } printf("Your Cost in Cart is %d\n",totalCost); break; } default:{ printf("Exit from Computer Accesories\n"); break; } } break; } case 2: { int shoesChoice; printf("Enter\n1 - Adidas - Rs.3550\n2 - Nike - Rs.5000\n3 - Leecooper - Rs.2800\nAny other number to exit\n"); scanf("%d",&shoesChoice); cost[3]=3550; cost[4]=5000; cost[5]=2800; switch(shoesChoice) { case 1: { int num; printf("You chose Adidas Shoes for Rs.3550.Are you sure to buy.If 'Yes' Enter 1 else any number\n"); scanf("%d",&num); if(num==1) { a[3]++; totalCost+=3550; } printf("Your Cost in Cart is %d\n",totalCost); break; } case 2: { int num; printf("You chose Nike Shoes for Rs.5000.Are you sure to buy.If 'Yes' Enter 1 else any number\n"); scanf("%d",&num); if(num==1) { a[4]++; totalCost+=5000; } printf("Your Cost in Cart is %d\n",totalCost); break; } case 3: { int num; printf("You chose Leecooper Shoes for Rs.2800.Are you sure to buy.If 'Yes' Enter 1 else any number\n"); scanf("%d",&num); if(num==1) { a[5]++; totalCost+=2800; } printf("Your Cost in Cart is %d\n",totalCost); break; } default:{ printf("Exit from Shoes Category\n"); break; } } break; } case 3: { int mobileChoice; printf("Enter\n1 - Mi Note 3 - Rs.11000\n2 - Nokia 3 - Rs.9866\n3 - Samsung - Rs.12800\nAny other number to exit\n"); scanf("%d",&mobileChoice); cost[6]=11000; cost[7]=9866; cost[8]=12800; switch(mobileChoice) { case 1: { int num; printf("You chose to buy Mi Note 3 for Rs.11000.Are you sure to buy.If 'Yes' Enter 1 else any number\n"); scanf("%d",&num); if(num==1) { a[6]++; totalCost+=11000; } printf("Your Cost in Cart is %d\n",totalCost); break; } case 2: { int num; printf("You chose to buy Nokia 3 for Rs.9866.Are you sure to buy.If 'Yes' Enter 1 else any number\n"); scanf("%d",&num); if(num==1) { a[7]++; totalCost+=9866; } printf("Your Cost in Cart is %d\n",totalCost); break; } case 3: { int num; printf("You chose to buy Samsung for Rs.12800.Are you sure to buy.If 'Yes' Enter 1 else any number\n"); scanf("%d",&num); if(num==1) { a[8]++; totalCost+=12800; } printf("Your Cost in Cart is %d\n",totalCost); break; } default:{ printf("Exit from Mobile Category\n"); break; } } break; } default: { printf("Enter Valid Categories Choice\n"); break; } } printf("%s's cart\n",str); printf("Id\tItems\t\t\tQuantity\t\t\tCost\n"); for(i=0;i<9;i++) { if(a[i]!=0) { printf("%d\t%s\t\t%d\t\t\t%d\n",i,items[i],a[i],(cost[i]*a[i])); } } printf("Total Cost\t\t\t\t\t%d\n",totalCost); printf("If you wish to buy anything more Enter\n1 to Add Item\n2 to Delete Items \nAny other number to Exit\n"); scanf("%d",&c); } if(c==2) { int id; printf("Enter id to delete item\n"); scanf("%d",&id); if(id<9&&id>0){ totalCost=totalCost-(cost[id]*a[id]); a[id]=0; } else{ printf("Enter Valid id\n"); } printf("Revised Items \n"); printf("Id\tItems\t\t\tQuantity\t\tCost\n"); for(i=0;i<9;i++) { if(a[i]!=0) { printf("%d\t%s\t\t%d\t\t%d\n",i,items[i],a[i],(cost[i]*a[i])); } } printf("Total Cost\t\t\t\t\t%d\n",totalCost); printf("If you wish to buy anything more Enter\n1 to Add Item\n2 to Delete Items \nAny other number to Exit\n"); scanf("%d",&c); } }while(c==1 || c==2); printf("Your Final Cost is %d\n",totalCost); printf("Thanks %s for Choosing Us and Visit us again.\n",str); }
Online Shopping including Change in Quantity
#include<stdio.h> #include<string.h> main() { static int totalCost; int i,j,choice,c=1,a[9],cost[9]; for(i=0;i<9;i++) a[i]=0; char str[100]; char items[9][100]={"Sandisk 16 GB", "Logitech Mouse", "Pendrve 16 GB", "Adidas", "Nike", "Leecooper", "Mi Note 3", "Nokia 3", "Samsung" }; printf("Please Enter Your Name\n"); gets(str); printf("Hello %s, Welcome to our Online Shopping.\n",str); do{ //C is 1 by default if(c==1){ printf("Enter\n1 - Computer Accessories\n2 - Shoes\n3 - Mobiles\nAny other number to exit\n"); scanf("%d",&choice); switch(choice) { case 1: { int accessoriesChoice; printf("Enter\n1 - Sandisk 16 GB - Rs.355\n2 - Logitech Mouse- Rs.500\n3 - Pendrive 16 GB - Rs.550\nAny other number to exit\n"); scanf("%d",&accessoriesChoice); cost[0]=355; cost[1]=500; cost[2]=550; switch(accessoriesChoice) { case 1: { int num; printf("You chose Sandisk 16GB with Rs.355.Are you sure to buy.If 'Yes' Enter 1 else any number\n"); scanf("%d",&num); if(num==1) { a[0]++; totalCost+=355; } printf("Your Cost in Cart is %d\n",totalCost); break; } case 2: { int num; printf("You chose Logitech Mouse with Rs.500.Are you sure to buy.If 'Yes' Enter 1 else any number\n"); scanf("%d",&num); if(num==1) { a[1]++; totalCost+=500; } printf("Your Cost in Cart is %d\n",totalCost); break; } case 3: { int num; printf("You chose Pendrive 16GB with Rs.550.Are you sure to buy.If 'Yes' Enter 1 else any number\n"); scanf("%d",&num); if(num==1) { a[2]++; totalCost+=550; } printf("Your Cost in Cart is %d\n",totalCost); break; } default:{ printf("Exit from Computer Accesories\n"); break; } } break; } case 2: { int shoesChoice; printf("Enter\n1 - Adidas - Rs.3550\n2 - Nike - Rs.5000\n3 - Leecooper - Rs.2800\nAny other number to exit\n"); scanf("%d",&shoesChoice); cost[3]=3550; cost[4]=5000; cost[5]=2800; switch(shoesChoice) { case 1: { int num; printf("You chose Adidas Shoes for Rs.3550.Are you sure to buy.If 'Yes' Enter 1 else any number\n"); scanf("%d",&num); if(num==1) { a[3]++; totalCost+=3550; } printf("Your Cost in Cart is %d\n",totalCost); break; } case 2: { int num; printf("You chose Nike Shoes for Rs.5000.Are you sure to buy.If 'Yes' Enter 1 else any number\n"); scanf("%d",&num); if(num==1) { a[4]++; totalCost+=5000; } printf("Your Cost in Cart is %d\n",totalCost); break; } case 3: { int num; printf("You chose Leecooper Shoes for Rs.2800.Are you sure to buy.If 'Yes' Enter 1 else any number\n"); scanf("%d",&num); if(num==1) { a[5]++; totalCost+=2800; } printf("Your Cost in Cart is %d\n",totalCost); break; } default:{ printf("Exit from Shoes Category\n"); break; } } break; } case 3: { int mobileChoice; printf("Enter\n1 - Mi Note 3 - Rs.11000\n2 - Nokia 3 - Rs.9866\n3 - Samsung - Rs.12800\nAny other number to exit\n"); scanf("%d",&mobileChoice); cost[6]=11000; cost[7]=9866; cost[8]=12800; switch(mobileChoice) { case 1: { int num; printf("You chose to buy Mi Note 3 for Rs.11000.Are you sure to buy.If 'Yes' Enter 1 else any number\n"); scanf("%d",&num); if(num==1) { a[6]++; totalCost+=11000; } printf("Your Cost in Cart is %d\n",totalCost); break; } case 2: { int num; printf("You chose to buy Nokia 3 for Rs.9866.Are you sure to buy.If 'Yes' Enter 1 else any number\n"); scanf("%d",&num); if(num==1) { a[7]++; totalCost+=9866; } printf("Your Cost in Cart is %d\n",totalCost); break; } case 3: { int num; printf("You chose to buy Samsung for Rs.12800.Are you sure to buy.If 'Yes' Enter 1 else any number\n"); scanf("%d",&num); if(num==1) { a[8]++; totalCost+=12800; } printf("Your Cost in Cart is %d\n",totalCost); break; } default:{ printf("Exit from Mobile Category\n"); break; } } break; } default: { printf("Enter Valid Categories Choice\n"); break; } } printf("%s's cart\n",str); printf("Id\tItems\t\tQuantity\tCost\n"); for(i=0;i<9;i++) { if(a[i]!=0) { printf("%d\t%s\t\t%d\t\t\t%d\n",i,items[i],a[i],(cost[i]*a[i])); } } printf("Total Cost\t\t\t\t\t%d\n",totalCost); printf("If you wish to buy anything more Enter\n1 to Add Item\n2 to Delete Items\n3 to Change Quantity \nAny other number to Exit\n"); scanf("%d",&c); } if(c==2) { int id; printf("Enter id to delete item\n"); scanf("%d",&id); if(id<9&&id>0){ totalCost=totalCost-(cost[id]*a[id]); a[id]=0; } else{ printf("Enter Valid id\n"); } printf("Revised Items \n"); printf("Id\tItems\t\tQuantity\tCost\n"); for(i=0;i<9;i++) { if(a[i]!=0) { printf("%d\t%s\t%d\t\t%d\n",i,items[i],a[i],(cost[i]*a[i])); } } printf("Total Cost\t\t\t\t\t%d\n",totalCost); printf("If you wish to buy anything more Enter\n1 to Add Item\n2 to Delete Items\n3 to Change Quantity \nAny other number to Exit\n"); scanf("%d",&c); } if(c==3) { int id,quantity; printf("Enter id to Change quantity of an item\n"); scanf("%d",&id); printf("Enter quantity to be changed of an item\n"); scanf("%d",&quantity); if(id<9&&id>0){ if(quantity>0 && a[id]>0){ if(quantity<a[id]) { int dec=a[id]-quantity; a[id]=quantity; totalCost=totalCost-(cost[id]*dec); } if(quantity>a[id]) { int inc=quantity-a[id]; a[id]=quantity; totalCost=totalCost+(cost[id]*inc); } if(quantity==a[id]) { a[id]=quantity; totalCost=totalCost+0; } } else{ printf("Item has no Quantity.Please Try again\n"); } } else{ printf("Enter Valid id\n"); } printf("Revised Items \n"); printf("Id\tItems\t\tQuantity\tCost\n"); for(i=0;i<9;i++) { if(a[i]!=0) { printf("%d\t%s\t%d\t\t%d\n",i,items[i],a[i],(cost[i]*a[i])); } } printf("Total Cost\t\t\t\t\t%d\n",totalCost); printf("If you wish to buy anything more Enter\n1 to Add Item\n2 to Delete Items\n3 to Change Quantity \nAny other number to Exit\n"); scanf("%d",&c); } }while(c==1 || c==2 ||c==3); printf("Your Final Cost is %d\n",totalCost); printf("Thanks %s for Choosing Us and Visit us again.\n",str); }
Explanation:
//Coming Soon
Output:
Hello, an amazing Information dude. Thanks for sharing this nice information with us. Online Selling Sites in India
ReplyDeleteThis is my first time i visit here and I found so many interesting stuff in your blog especially it's discussion, thank you. buy online
ReplyDeleteThanks admin for sharing this wonderful post.
ReplyDeleteOnline Shopping in Pakistan
Stroke strikes 700,000 unsuspecting victims every year. But new imaging technology, like ultrasound scans, and emerging insights into causes Blunt Smokers
ReplyDeleteThere are plenty of dissertation web sites over the internet while you obtain not surprisingly detailed in the webpage. Flash disks for sale in Kenya
ReplyDeleteDigital marketing agecny
ReplyDeleteDigital marketing agecny
Digital marketing agecny
Digital marketing agecny
Digital marketing agecny
Digital marketing agecny
Digital marketing agecny
Digital marketing agecny
Digital marketing agecny
Digital marketing agecny
Digital marketing agecny
Digital marketing agecny
Digital marketing agecny
Digital marketing agecny
Digital marketing agecny
Digital marketing agecny
Digital marketing agecny
Digital marketing agecny
Digital marketing agecny
Digital marketing agecny
Digital marketing agecny
Digital marketing agecny
Digital marketing agecny
Digital marketing agecny
Digital marketing agecny
Digital marketing agecny
Digital marketing agecny
Digital marketing agecny
Digital marketing agecny
Digital marketing agecny
Ongoing examination led by the Australian Intuitive Media Industry Affiliation (AIMIA) authorized by Sensis Pty Ltd (May 2011, p. 10) demonstrates, that "62% of Australian Web clients utilize an assortment of social media destinations, with many visiting each day and most at any rate a couple of times each week.cheap smm panel
ReplyDeleteVery useful info. Hope to see more posts soon!. Custom Velcro Patches
ReplyDeleteLike my websit and blog Pilarwin
ReplyDeleteWeb smoothing out infers the way toward making a site persistently detectable on a web crawler's outcomes page. To explain, a faltering SEO reasoning will put an affiliation's site at the head of the rundown on a Google search page, thusly improving the probability that individuals will visit the site.
ReplyDeletehttps://5euros.eu/profil/netbiz
Positive site, where did u think about the information on this posting? I'm fulfilled I thought that it was nonetheless, wiped out be asking soon to find what additional posts you join.
ReplyDeletetesteurs-outdoor.com
I curious more interest in some of them hope you will give more information on this topics in your next articles. best coffee by region, the best places to grow coffee
ReplyDeleteLand esteems have taken a jump and one of the outcomes has prompted there being many, a lot more properties available currently contrasted with before the economy took a make a plunge 2008. This implies despite the fact that the costs are lower, the higher amount of properties available make it conceivable to purchase and sell a greater amount of them and get more cash-flow in commissions accordingly which will more than compensate for the diminished individual property estimations.
ReplyDeletemandat de gestion de portefeuille
JewelryShop.pk Buy jewellery online in Pakistan - We provide Artificial Rings, Earrings, Jewellery Sets, Bracelets & all types of women's fashion jewellery in Pakistan.
ReplyDeleteGreat Article Artificial Intelligence Projects
ReplyDeleteProject Center in Chennai
JavaScript Training in Chennai
JavaScript Training in Chennai
Much the same as building a multitude of connections won't assist you with saving traffic for long, having great substance and nothing else is likewise insufficient. SEO
ReplyDeleteDid you know that there are shopping malls online where you can buy virtually anything you need? From electronics to insurance to toilet paper and the list goes on and on eco-friendly products online
ReplyDeleteI’ll immediately grab your rss as I can’t find your email subscription link or e-newsletter service. Do you have any? Kindly let me know so that I could subscribe. Thanks. 토토사이트
ReplyDeleteAn example of this can be Atypical Mole Syndrome. This syndrome brings about a tendency within the body to type an excessive amount of moles on our skin. This really is something that we could have obtained from our parents or our grandparents and we’ve no manage over whether or not we receive it or not. 파워볼사이트
ReplyDeleteThe accompanying connections are instances of robotized SEO programming unreservedly accessible on the Web. Webdesign Kortessem
ReplyDeleteI found your this post while searching for information about blog-related research ... It's a good post .. keep posting and updating information. OrbitEx
ReplyDeleteI added a favicon, which I thought may make my webpage look more expert and some extravagant catches connecting to different pages on my area, and I remembered a couple of recordings for my posts, all utilizing free online marketing devices I may add.SEO
ReplyDeleteChoose with your paying organization: Be clear with your installment design, regardless of whether utilizing your credit, charge or charge card prior to shopping, for making your shopping safe. nemzetközi szállítmányozás Europa-Road Kft.
ReplyDeleteIf you do a survey to create a list of the most popular hobbies of people in the United States of America, then shopping would definitely be somewhere at the top of the list. It is surprising to learn that people see shopping as a hobby more than something which is done out of necessity. However, it is not just in USA that people are passionate about shopping. https://toptoy365.creatorlink.net/
ReplyDeleteWe’ve been creating elegant digital printing for over 20 years. Right from the start of the digital printing revolution, in fact. In that time we have grown with you, our clients. And the thing is, like any important relationship check our website for more info custom stickers printing
ReplyDeleteA SEO mission will require 6-year and a half to convey the top results you anticipate. Ensure you don't surrender to bogus vows. https://www.webdesign-seo-limburg.be/
ReplyDeleteIn an examination of in excess of 5,800 private companies (arriving at an organization of 4.6 million independent ventures), the exploration featured the harm brought about by the pandemic. The outcomes indicated apparent harm of the pandemic. At this point, 43% of organizations had briefly shut, and virtually these terminations were because of COVID-19.In an examination of in excess of 5,800 private companies (arriving at an organization of 4.6 million independent ventures), the exploration featured the harm brought about by the pandemic. The outcomes indicated apparent harm of the pandemic. At this point, 43% of organizations had briefly shut, and virtually these terminations were because of COVID-19. my review here
ReplyDeleteJust admiring your work and wondering how you managed this blog so well. It’s so remarkable that I can't afford to not go through this valuable information whenever I surf the internet! เช็คพัสดุ
ReplyDeleteI really appreciate this wonderful post that you have provided for us. I assure this would be beneficial for most of the people. Email Extractor
ReplyDeleteUnless you are escaping to a desert island for the whole of December, Christmas shopping is pretty much unavoidable but if your local shops just aren't going cut it this year (and you don't want to rely on the post!), then why not use this guide to head out to the best shopping locations in the UK? Pre-Christmas sales are not uncommon now so search around for some real bargains. Expressvpn deal
ReplyDelete