The Question: Write a function main that prompts a user to enter the number of different items that he intends to purchase from a showroom.Your program should read for each item the quantity to purchase and the unit price then finally display total amount to be paid

anyone help me with my codes i am really stuck i am having those errors:
1.switch quantity not an integer
2.case label not within a switch statement
3.break statement not within loop or switch

#include<stdio.h>
#include<stdlib.h>

float ComputeAmount(int x, int y);

int main()
{
    int a, totalAmount, z, k;

    printf("Enter number of different items to be purchased: ");
    scanf("%d", &a);

    totalAmount=ComputeAmount(z,k);

    system("pause");
    return 0;
}
float ComputeAmount(int x, int y){

      int a, totalAmount, k, z;

      printf("Enter quantity: ");
      scanf("%d", &z);

      printf("1: k<=100");
      printf("2: k<=200");
      printf("3: k<=300");
      printf("4: k>300");

      printf("Enter amount: ");
      scanf("%d", &k);

      switch("k");{
                   case 1:{totalAmount=z*k;
                        break;
                        }
                   case 2:{totalAmount=z*(k*0.05);
                        break;
                        }     
                }
      return (totalAmount);

      }

Line 33: Remove the " and the ;
On line 31 you read in the integer variable k, you don't have to place double quotes around it in the switch.

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.