Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/date/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ada 形式参数";项目「;未被引用_Ada - Fatal编程技术网

Ada 形式参数";项目「;未被引用

Ada 形式参数";项目「;未被引用,ada,Ada,通过使用子程序,我尝试编写一个显示VAT表的程序。它要求用户输入一些数据,并根据这些数据显示增值税表。但是,我收到一条警告:“形式参数”项“未被引用”。我的程序确实显示了一个表,但它看起来很糟糕。在这里你可以看到我已经走了多远: with Ada.Text_IO; use Ada.Text_IO; with Ada.Integer_Text_IO; use Ada.Integer_Text_IO; with Ada.Float_Text

通过使用子程序,我尝试编写一个显示VAT表的程序。它要求用户输入一些数据,并根据这些数据显示增值税表。但是,我收到一条警告:“形式参数”项“未被引用”。我的程序确实显示了一个表,但它看起来很糟糕。在这里你可以看到我已经走了多远:

with Ada.Text_IO;                    use Ada.Text_IO;
with Ada.Integer_Text_IO;            use Ada.Integer_Text_IO;
with Ada.Float_Text_IO;              use Ada.Float_Text_IO;

procedure Underprogram is
V_percent, S_length, H_price, L_price, Price_Wm : Float;
 X: Integer;

procedure Get_Pop(Item : out Float ) is
begin
  Put_Line("Write ur first price:");
Get(H_price, width=>0);
while H_price < 0.0 loop
  Put("Wrong inout, try again! : ");
  Get(H_price);
end loop;

loop
Put_Line("Write in your second price:");
  Get(L_price, width=>0);
  if H_price > L_price then
  exit; end if; end loop;

Put_Line("Which VAT percent do ypu want? ");
Get(V_percent, width=>0);
while V_percent > 100.0 or V_percent <= 0.0 loop
  Put_Line("The vat percent you fed in is invalid, try again! ");
  Get(V_percent);
  end loop;

Put_Line("Which step length do you want? ");
Get(S_length, width=>0);
while S_length < 0.1 or S_length > 1.0 loop
  Put_Line("The step length you just fed in is out of the range: ");
  Get(S_length);
end loop;  end Get_Pop;

procedure Put_pop(Item : in Float) is
  
  begin
  X := Integer(Float'Floor((H_price-L_price) / S_length + 1.0));
Put_Line("              === Vattabell ===               ");
Put_Line("Price without VAT    Vat      Price with VAT ");
Put_Line("---------------     ----      -------------- ");
for I in 0..X -1  loop

 Price_Wm := L_price + Float(I) * S_length;
 Put(Price_Wm, 5,2,0);

 Put((L_price + Float(I) * S_length) * V_percent/100.0,
      13,2,0);

  Put(Price_Wm * (1.0 +  V_percent/100.0), 15,2,0);

  New_Line;
end loop;
  end Put_pop;
begin
Get_Pop(V_percent); Put_pop(V_percent);
Get_Pop(S_length);  Put_pop(S_length);
Get_Pop(H_price); Put_pop(H_price);
Get_Pop(L_price); Put_pop(L_price);
Get_Pop(Price_Wm); Put_pop(Price_Wm);
  end Underprogram;
with Ada.Text_IO;         use Ada.Text_IO;
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;
with Ada.Float_Text_IO;   use Ada.Float_Text_IO;
  
procedure Underprogram is
Higher, Lower, VAT, Step, Price_without_VAT: Float;
X                        : Integer;
procedure Get_data(Item: out Float) is
begin
  Get(Item);
end Get_data;
procedure Put_data(Item: in Float) is
begin
  Put(Item, 2,2,0); Put(" ");
end Put_data;
begin
Put("Write the higher price: ");
Get_data(Higher);
while Higher < 0.0 loop
Put("Wrong input, try again: ");
Get_data(Higher); end loop;
  
loop
Put("Write the lower price: ");
     Get_data(Lower);
     if Lower < Higher then
        exit; end if; end loop;
     
  Put("Write the VAT : ");
  Get_data(VAT);
  while VAT > 100.0 or VAT < 0.0 loop
     Put("Wrong input, try again:");
     Get_data(VAT);
     end loop;
     
     loop
        Put("Write the step: ");
        Get_data(Step);
        if Step > 0.0 then
        exit; end if; end loop;
 Put_data(Higher);
 Put_data(Lower);
 Put_data(VAT);
 Put_data(Step);

 X := Integer(Float'Floor((Higher-Lower) / Step + 1.0));
Put_Line("              === VATTABELL ===               ");
Put_Line("Price without VAT      VAT      Price with VAT ");
Put_Line("---------------     ----      -------------- ");
for I in 0..X -1  loop

  Price_without_VAT := Higher + Float(I) * Step;
  Put(Price_without_VAT, 5,2,0);
  Put((Higher + Float(I) * Step) * VAT/100.0, 13,2,0);
  Put(Price_without_VAT * (1.0 +  VAT/100.0), 15,2,0);
  New_Line;
end loop;
end Underprogram;
带有Ada.Text\u IO;使用Ada.Text\u IO;
使用Ada.Integer\u Text\u IO;使用Ada.Integer\u Text\u IO;
使用Ada.Float_Text_IO;使用Ada.Float\u Text\u IO;
程序子程序是
V_百分比、S_长度、H_价格、L_价格、价格_Wm:浮动;
X:整数;
程序Get_Pop(项目:out Float)为
开始
写上一行(“写下你的第一个价格:”);
获取(H_价格,宽度=>0);
而H_价格<0.0圈
输入(“输入错误,再试一次!”);
获取(H_价格);
端环;
环
写上一行(“写下你的第二个价格:”);
获取(L_价格,宽度=>0);
如果H_价格>L_价格,则
出口如果结束;端环;
放线(“ypu想要多少增值税百分比?”);
获取(V_百分比,宽度=>0);
而V_百分比>100.0或V_百分比为0);
当S_长度<0.1或S_长度>1.0圈时
Put_Line(“刚输入的步长超出范围:”);
Get(S_长度);
端环;结束获得流行音乐;
程序Put_pop(项目:浮动)为
开始
X:=整数(浮动下限((H_价格-L_价格)/S_长度+1.0));
放线(“==Vattabell==”);
放线(“不含增值税的价格,含增值税的价格”);
放线(“-------------------”;
对于0..X-1循环中的I
价格:L价格+浮动(I)*S长度;
看跌期权(价格,5,2,0);
认沽权((L_价格+浮动(I)*S_长度)*V_百分比/100.0,
13,2,0);
看跌期权(价格(1.0+V百分之/100.0),15,2,0);
新线;
端环;
结束播放;
开始
获得流行音乐(V_百分比);Put_pop(V_百分比);
获取_Pop(S_长度);Put_pop(S_长度);
获得流行音乐(H_价格);看跌期权(H_价格);
获得流行音乐(L_价格);卖出价(卖出价);
获得流行音乐(价格);Put_pop(价格);
末端子程序;
这里有一个更新:我只是根据注释重写了代码,效果很好。现在我想知道如何在代码中添加更多的函数和子程序,从而使底层程序看起来更干净?。现在我只有两个子程序:

with Ada.Text_IO;                    use Ada.Text_IO;
with Ada.Integer_Text_IO;            use Ada.Integer_Text_IO;
with Ada.Float_Text_IO;              use Ada.Float_Text_IO;

procedure Underprogram is
V_percent, S_length, H_price, L_price, Price_Wm : Float;
 X: Integer;

procedure Get_Pop(Item : out Float ) is
begin
  Put_Line("Write ur first price:");
Get(H_price, width=>0);
while H_price < 0.0 loop
  Put("Wrong inout, try again! : ");
  Get(H_price);
end loop;

loop
Put_Line("Write in your second price:");
  Get(L_price, width=>0);
  if H_price > L_price then
  exit; end if; end loop;

Put_Line("Which VAT percent do ypu want? ");
Get(V_percent, width=>0);
while V_percent > 100.0 or V_percent <= 0.0 loop
  Put_Line("The vat percent you fed in is invalid, try again! ");
  Get(V_percent);
  end loop;

Put_Line("Which step length do you want? ");
Get(S_length, width=>0);
while S_length < 0.1 or S_length > 1.0 loop
  Put_Line("The step length you just fed in is out of the range: ");
  Get(S_length);
end loop;  end Get_Pop;

procedure Put_pop(Item : in Float) is
  
  begin
  X := Integer(Float'Floor((H_price-L_price) / S_length + 1.0));
Put_Line("              === Vattabell ===               ");
Put_Line("Price without VAT    Vat      Price with VAT ");
Put_Line("---------------     ----      -------------- ");
for I in 0..X -1  loop

 Price_Wm := L_price + Float(I) * S_length;
 Put(Price_Wm, 5,2,0);

 Put((L_price + Float(I) * S_length) * V_percent/100.0,
      13,2,0);

  Put(Price_Wm * (1.0 +  V_percent/100.0), 15,2,0);

  New_Line;
end loop;
  end Put_pop;
begin
Get_Pop(V_percent); Put_pop(V_percent);
Get_Pop(S_length);  Put_pop(S_length);
Get_Pop(H_price); Put_pop(H_price);
Get_Pop(L_price); Put_pop(L_price);
Get_Pop(Price_Wm); Put_pop(Price_Wm);
  end Underprogram;
with Ada.Text_IO;         use Ada.Text_IO;
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;
with Ada.Float_Text_IO;   use Ada.Float_Text_IO;
  
procedure Underprogram is
Higher, Lower, VAT, Step, Price_without_VAT: Float;
X                        : Integer;
procedure Get_data(Item: out Float) is
begin
  Get(Item);
end Get_data;
procedure Put_data(Item: in Float) is
begin
  Put(Item, 2,2,0); Put(" ");
end Put_data;
begin
Put("Write the higher price: ");
Get_data(Higher);
while Higher < 0.0 loop
Put("Wrong input, try again: ");
Get_data(Higher); end loop;
  
loop
Put("Write the lower price: ");
     Get_data(Lower);
     if Lower < Higher then
        exit; end if; end loop;
     
  Put("Write the VAT : ");
  Get_data(VAT);
  while VAT > 100.0 or VAT < 0.0 loop
     Put("Wrong input, try again:");
     Get_data(VAT);
     end loop;
     
     loop
        Put("Write the step: ");
        Get_data(Step);
        if Step > 0.0 then
        exit; end if; end loop;
 Put_data(Higher);
 Put_data(Lower);
 Put_data(VAT);
 Put_data(Step);

 X := Integer(Float'Floor((Higher-Lower) / Step + 1.0));
Put_Line("              === VATTABELL ===               ");
Put_Line("Price without VAT      VAT      Price with VAT ");
Put_Line("---------------     ----      -------------- ");
for I in 0..X -1  loop

  Price_without_VAT := Higher + Float(I) * Step;
  Put(Price_without_VAT, 5,2,0);
  Put((Higher + Float(I) * Step) * VAT/100.0, 13,2,0);
  Put(Price_without_VAT * (1.0 +  VAT/100.0), 15,2,0);
  New_Line;
end loop;
end Underprogram;
带有Ada.Text\u IO;使用Ada.Text\u IO;
使用Ada.Integer\u Text\u IO;使用Ada.Integer\u Text\u IO;
使用Ada.Float_Text_IO;使用Ada.Float\u Text\u IO;
程序子程序是
高、低、增值税、阶梯、价格(不含增值税):浮动;
X:整数;
程序Get_数据(项目:out Float)为
开始
获取(项目);
结束获取数据;
程序Put_数据(项目:浮动)为
开始
投入(第2、2、0项);以“-”号填列;
终端输出数据;
开始
卖出(“写出更高的价格:”);
获取_数据(更高);
而较高值<0.0圈
输入(“输入错误,请重试:”);
获取_数据(更高);端环;
环
卖出(“写出较低的价格:”);
获取_数据(较低);
如果较低<较高,则
出口如果结束;端环;
放(“写增值税:”);
获取_数据(VAT);
当VAT>100.0或VAT<0.0时
输入(“输入错误,请重试:”);
获取_数据(VAT);
端环;
环
Put(“写下步骤:”);
获取_数据(步骤);
如果步长>0.0,则
出口如果结束;端环;
Put_数据(更高);
Put_数据(较低);
Put_数据(增值税);
输入数据(步骤);
X:=整数(浮点数下限((高/低)/步长+1.0));
放线(“==VATTABELL==”);
放线(“不含增值税的价格,含增值税的价格”);
放线(“-------------------”;
对于0..X-1循环中的I
不含增值税的价格:=更高+浮动(I)*步;
卖出价(不含增值税的价格,5,2,0);
投入((较高+浮动(I)*步骤)*增值税/100.0,13,2,0);
卖出价(不含增值税的价格*(1.0+增值税/100.0),15,2,0);
新线;
端环;
末端子程序;

以下代码是由GNAT Studio 2020社区版中提供的漂亮打印机重新组织后的代码:

with Ada.Text_IO;         use Ada.Text_IO;
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;
with Ada.Float_Text_IO;   use Ada.Float_Text_IO;

procedure Underprogram is
   V_percent, S_length, H_price, L_price, Price_Wm : Float;
   X                                               : Integer;

   procedure Get_Pop (Item : out Float) is
   begin
      Put_Line ("Write ur first price:");
      Get (H_price, Width => 0);
      while H_price < 0.0 loop
         Put ("Wrong inout, try again! : ");
         Get (H_price);
      end loop;

      loop
         Put_Line ("Write in your second price:");
         Get (L_price, Width => 0);
         if H_price > L_price then
            exit;
         end if;
      end loop;

      Put_Line ("Which VAT percent do ypu want? ");
      Get (V_percent, Width => 0);
      while V_percent > 100.0 or V_percent <= 0.0 loop
         Put_Line ("The vat percent you fed in is invalid, try again! ");
         Get (V_percent);
      end loop;

      Put_Line ("Which step length do you want? ");
      Get (S_length, Width => 0);
      while S_length < 0.1 or S_length > 1.0 loop
         Put_Line ("The step length you just fed in is out of the range: ");
         Get (S_length);
      end loop;
   end Get_Pop;

   procedure Put_pop (Item : in Float) is

   begin
      X := Integer (Float'Floor ((H_price - L_price) / S_length + 1.0));
      Put_Line ("              === Vattabell ===               ");
      Put_Line ("Price without VAT    Vat      Price with VAT ");
      Put_Line ("---------------     ----      -------------- ");
      for I in 0 .. X - 1 loop

         Price_Wm := L_price + Float (I) * S_length;
         Put (Price_Wm, 5, 2, 0);

         Put ((L_price + Float (I) * S_length) * V_percent / 100.0, 13, 2, 0);

         Put (Price_Wm * (1.0 + V_percent / 100.0), 15, 2, 0);

         New_Line;
      end loop;
   end Put_pop;
begin
   Get_Pop (V_percent);
   Put_pop (V_percent);
   Get_Pop (S_length);
   Put_pop (S_length);
   Get_Pop (H_price);
   Put_pop (H_price);
   Get_Pop (L_price);
   Put_pop (L_price);
   Get_Pop (Price_Wm);
   Put_pop (Price_Wm);

end Underprogram;
带有Ada.Text\u IO;使用Ada.Text\u IO;
使用Ada.Integer\u Text\u IO;使用Ada.Integer\u Text\u IO;
使用Ada.Float_Text_IO;使用Ada.Float\u Text\u IO;
程序子程序是
V_百分比、S_长度、H_价格、L_价格、价格_Wm:浮动;
X:整数;
程序Get_Pop(项目:out Float)为
开始
写上一行(“写下你的第一个价格:”);
获取(H_价格,宽度=>0);
而H_价格<0.0圈
输入(“输入错误,再试一次!”);
获取(H_价格);
端环;
环
写上一行(“写下你的第二个价格:”);
获取(L_价格,宽度=>0);
如果H_价格>L_价格,则
出口
如果结束;
端环;
放线(“ypu想要多少增值税百分比?”);
获取(V_百分比,宽度=>0);
而V_百分比>100.0或V_百分比为0);
当S_长度<0.1或S_长度>1.0圈时
Put_Line(“刚输入的步长超出范围:”);
Get(S_长度);
端环;
结束获得流行音乐;
程序Put_pop(项目:浮动)为
开始
X:=整数(浮动下限((H_价格-L_价格)/S_长度+1.0));
放线(“==Vattabell==”);
放线(“不含增值税的价格,含增值税的价格”);
放线(“-------------------”;
因为我在0。。X-1回路
价格:L价格+浮动(I)*S长度;
看跌期权(价格,5,2,0);
看跌期权((市价+浮动(I)*市价长度)*市价百分比/100.0,13,2,0);
看跌期权(价格*(1.0+V百分之/100.0),15,2,0;
新线;
端环;
结束播放;
开始
获得流行音乐(V_百分比);
Put_pop(V_百分比);
获取_Pop(S_长度);
Put_pop(S_长度);
获得流行音乐(H_价格);
看跌期权(H_价格);
获得流行音乐(L_价格);
卖出价(卖出价);
获得流行音乐(价格);
Put_pop(价格);
末端子程序;
我只是简单地将源代码复制到GNATstudioIDE中,保存了文件